CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Main CFD Forum

CGNS Fortran Writing Error

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   August 21, 2012, 06:35
Default CGNS Fortran Writing Error
  #1
New Member
 
Join Date: Aug 2012
Posts: 22
Rep Power: 4
AeroMike is on a distinguished road
Hi all,

I have written a Fortran code which writes a structured grid, I used the NASA website which is a great help, and my code is heavily based on that.

Anyway, it works locally and I have tested the grids extensively. When I try to run it on the two HPC's I have access to it behaves very oddly - compiles okay, but crashes out with an error that:

VertexSize[0]=71 and CellSize[0]=0

If I print the isize(1,2) immediately before the cgns call it is 70 as expected but seems to go wrong in the call.

Placing print statements in the code seems to cause it to misbehave a bit (sometimes my cgns error becomes "no cgns error"!).

I am using 64 bit cgns and compiling with all my integers as 8 bit. Has anyone experienced a similar problem and/or can hazard a guess at what could be going wrong?!

Thanks for any help,
Mike
AeroMike is offline   Reply With Quote

Old   April 10, 2013, 08:26
Default
  #2
New Member
 
Ben Hinchliffe
Join Date: Mar 2013
Posts: 13
Rep Power: 4
bensciens is on a distinguished road
I have recently been getting this error myself using Fortran and the CGNS libraries.

Did you solve the problem?
bensciens is offline   Reply With Quote

Old   April 10, 2013, 08:34
Default
  #3
New Member
 
Join Date: Aug 2012
Posts: 22
Rep Power: 4
AeroMike is on a distinguished road
Hi Ben,

Yes, but it was a while back and I can't be sure what I'm about to tell you is correct, but it is something which I know fixed some of my mistakes.

You have to be very careful writing integers to any of the cgns routines. There is a cgns type variable you should use for all integers, "cgsize_t".

The place where it catches me out is in the bc's where you always write a fixed "2". But you must declare a cgsize_t:: fixed_bc_length and set the variable to 2 or it sometimes will fail.

I'm not sure if that is the actual solution though. If that doesn't work let me know and I'll hunt through git and find my change log for August last year!
AeroMike is offline   Reply With Quote

Old   April 10, 2013, 08:52
Default
  #4
New Member
 
Ben Hinchliffe
Join Date: Mar 2013
Posts: 13
Rep Power: 4
bensciens is on a distinguished road
Thanks for the quick reply Mike.
I'm not entirely sure how to use cgsize_t for integers.

Are you saying that my problem comes from using isize declared as:

INTEGER:: isize(3,3)

This is then used to store the VERTEXSIZE, CELLSIZE and bc:

isize(1,1) = in(nb)
isize(2,1) = jn(nb)
isize(3,1) = kn(nb)
isize(1,2) = isize(1,1)-1
isize(2,2) = isize(2,1)-1
isize(3,2) = isize(3,1)-1
isize(1,3) = 0
isize(2,3) = 0
isize(3,3) = 0

where nb is the block number.
Directly below is the call function:

CALL cg_zone_write_f(index_file, index_base, zonename(nb), isize, Structured, index_zone(nb), ier)
IF (ier .NE. 0) CALL cg_error_exit_f

This is for a structured grid.

Any further help you can give me is much appreciated.

Ben
bensciens is offline   Reply With Quote

Old   April 10, 2013, 08:55
Default
  #5
New Member
 
Join Date: Aug 2012
Posts: 22
Rep Power: 4
AeroMike is on a distinguished road
I think so yes, in my code I have them all declared like that:

!> CGNS identifiers
cgsize_t :: IER
cgsize_t:: ICELLDIM,IPHYSDIM
cgsize_t, DIMENSION(3,3) :: ISIZE
cgsize_t :: INDEX_FILE,INDEX_BASE,INDEX_ZONE,INDEX_COORD
CHARACTER*32, ALLOCATABLE, DIMENSION(:: BASENAME, ZONENAME
AeroMike is offline   Reply With Quote

Old   April 10, 2013, 08:56
Default
  #6
New Member
 
Join Date: Aug 2012
Posts: 22
Rep Power: 4
AeroMike is on a distinguished road
PS: You will have to have included the lines:

include 'cgnslib_f.h'

#include "cgnstypes_f.h"

In your header too (I'm not sure what the # is for but it seems to be required!).
AeroMike is offline   Reply With Quote

Old   April 10, 2013, 09:01
Default
  #7
New Member
 
Ben Hinchliffe
Join Date: Mar 2013
Posts: 13
Rep Power: 4
bensciens is on a distinguished road
Thank you,

Just found another way around it, from the information I have read it seems to be something to do with compiling in 32/64-bit.

Your way is probably the better way but changing the declaration for isize to:

for 64-bit
INTEGER*8 :: isize(3,3)

for 32-bit
INTEGER*4 :: isize(3,3)

This also seems to work.

Thank you for your help Mike.
bensciens is offline   Reply With Quote

Old   April 10, 2013, 09:04
Default
  #8
New Member
 
Join Date: Aug 2012
Posts: 22
Rep Power: 4
AeroMike is on a distinguished road
Hi.

Yes, you can change it manually and it should work. But this means that you will need to make sure that you always check it when you switch to a new machine. This will inevetibly cause trouble when you switch to a different HPC, or more likely, when the code gets passed on to someone else and they have the same problem again.

All cgsize_t does is check which cgns library is installed and choose the appropriate integer size, which allows you to compile it hassle free on any machine.

Glad it's working though!

Mike
AeroMike is offline   Reply With Quote

Old   April 10, 2013, 09:37
Default
  #9
New Member
 
Ben Hinchliffe
Join Date: Mar 2013
Posts: 13
Rep Power: 4
bensciens is on a distinguished road
I'm trying to compile with

#INCLUDE "cgnstypes_f.h"

but I'm getting a 'Bad # preprocessor line'.

Were you using ifort?
bensciens is offline   Reply With Quote

Old   April 10, 2013, 09:42
Default
  #10
New Member
 
Join Date: Aug 2012
Posts: 22
Rep Power: 4
AeroMike is on a distinguished road
You must use both lines:

include 'cgnslib_f.h'

#include "cgnstypes_f.h"

I'm not sure why you get an error then though, I can compile with ifort or gfortran and both work.
AeroMike is offline   Reply With Quote

Old   April 10, 2013, 09:45
Default
  #11
New Member
 
Ben Hinchliffe
Join Date: Mar 2013
Posts: 13
Rep Power: 4
bensciens is on a distinguished road
I have both if I don't include the '#' the error applies to the hashes lines inside
cgnstypes_f.h.

Do you know what compiler options you used?
bensciens is offline   Reply With Quote

Old   April 10, 2013, 09:50
Default
  #12
New Member
 
Join Date: Aug 2012
Posts: 22
Rep Power: 4
AeroMike is on a distinguished road
You must make sure that the first of the two lines is indenteded and the second isn't at all. The first must not be #'d and the second must. I'm not sure why, but I think that this exactly the formatting it must be. I can't say why though!

E.G exact formatting below.

IMPLICIT NONE
include 'cgnslib_f.h'

#include "cgnstypes_f.h"

Now, as for compiler options it shouldn't matter, I have debug flags and that works or just compiling with -O3 -r8 -i4 -fpp should work too.
AeroMike is offline   Reply With Quote

Old   April 10, 2013, 09:58
Default
  #13
New Member
 
Ben Hinchliffe
Join Date: Mar 2013
Posts: 13
Rep Power: 4
bensciens is on a distinguished road
Got it!

I had everything but the -fpp flag. It works for now just a fault because I made a vector the wrong size somewhere.

Thanks for the help.
bensciens is offline   Reply With Quote

Old   April 10, 2013, 10:00
Default
  #14
New Member
 
Join Date: Aug 2012
Posts: 22
Rep Power: 4
AeroMike is on a distinguished road
Yeah, I can't be held responsible for other bugs in your code ;-)

Glad it's working now though.
AeroMike is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Native ParaView Reader Bugs tj22 OpenFOAM Paraview & paraFoam 267 July 20, 2015 22:29
CGNS Compiling Diego Main CFD Forum 17 December 21, 2014 02:40
Version 15 on Mac OS X gschaider OpenFOAM Installation 120 December 2, 2009 11:23
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50
user defined function cfduser CFX 0 April 29, 2006 10:58


All times are GMT -4. The time now is 10:50.