Opened 6 years ago

Last modified 6 years ago

#967 new defect

GRHydro uses EOS_Omni routines without DECLARE_CCTK_FUNCTIONS

Reported by: Roland Haas Owned by:
Priority: minor Milestone:
Component: EinsteinToolkit thorn Version:
Keywords: GRHydro Cc:


and adding DECLARE_CCTK_FUNCTIONS eg. in ConservativeToPrimitive reveals that we pass scalars to EOS_Omni routines that would expect (1 element) arrays.

Making them (pmin, epsmin, rhomin are affected) all arrays makes the code very ugly (even for GRHydro) :-).

Attachments (0)

Change History (3)

comment:1 Changed 6 years ago by Erik Schnetter

Is the array/scalar mismatch an error? To my knowledge, the standard forbids it, but it works fine in all implementations.

Converting a scalar "rho" to an array would look like this: "(/rho/)".

comment:2 Changed 6 years ago by Roland Haas

I get errors out of gfortran 4.7 and I think also out of earlier versions. Typically (ie. after adding DECLARE_CCTK_FUNCTIONS to Conservative2Primitive):


call EOS_Omni_press(GRHydro_polytrope_handle,keytemp,GRHydro_eos_rf_prec,n,&
Error: Rank mismatch in argument 'rho' at (1) (rank-1 and scalar)

So you are saying:

call EOS_Pressure(eos_handle,...,/rho_min/,...,/press_min/)

is legal even for cases where rho_min is only read but press_min is written to?

Last edited 6 years ago by Roland Haas (previous) (diff)

comment:3 Changed 6 years ago by Erik Schnetter

The syntax is (/rho_min/); the parentheses are necessary.

No, this is only for variables that are read. If the variables are also written, then I would recommend using pointers (or temporary arrays with copy-in and copy-out, but this is cumbersome).

  subroutine call_with_array(b)
    integer b
    integer a(1)
    pointer (pa,a)
    pa = loc(b)
    call wantarray(a)

This defined a subroutine with a scalar argument b. The subroutine defines a pointer variable pa, pointing to an array. (No space is allocated for an array.) The pointer is set to the address of b. The pointer is dereferenced (in C parlance) by using its "other name". In C, this code corresponds to something like

  int b;
  int[1] *pa;
  pa = &b;

(except that int[1] is not a type in C, so one would have to wrap it into a structure, and this would make the C version of this example more complex than necessary).

Modify Ticket

Change Properties
Set your email in Preferences
as new The ticket will remain with no owner.
Next status will be 'review'.
as The resolution will be set.
to The owner will be changed from (none) to the specified user.
Next status will be 'confirmed'.
The owner will be changed from (none) to anonymous.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.