Comscw.f pointer attribute error

Dear experts,
A custom user routine has been written to score the averaged track KE and LET in 3D array using comscw.f template along side with with other two subroutines. We used to run these subroutines in FLUKA.org and its GUI flair 2.3. Recently, I’m trying to compile and create an executable on flair 3.1-13 but it outputs the next error:
…/comscw.f:191:12:

191 | ke_array(xidx,yidx,zidx) = ke_array(xidx,yidx,zidx) + KE
| 1
Error: The function result on the lhs of the assignment at (1) must have the pointer attribute.
…/comscw.f:192:12:

Ended: 2021.04.23 12:45:02

Error compiling
Error: compiling file: …/comscw.f
No object generated

Any suggestion to resolve this issue would be appreciated.

Thank you
Abdul

Dear Abdul,

can you share the whole user routine?

Cheers,
David

here you go
comscw.f (9.4 KB)

Thank you
Abdul

Dear Abdul,

the variables ke_array, cnt_array, let_array and nlet_array are not not declared as arrays.

Cheers,
David

Thank you David for clarification,
I’m not an expert in coding but I’ve added the following lines:
DOUBLE PRECISION,DIMENSION(:,:,:),ALLOCATABLE::ke_array
DOUBLE PRECISION,DIMENSION(:,:,:),ALLOCATABLE::cnt_array
DOUBLE PRECISION,DIMENSION(:,:,:),ALLOCATABLE::let_array
DOUBLE PRECISION,DIMENSION(:,:,:),ALLOCATABLE::nlet_array
then flair has successfully compiled the subroutines and generated executable, when I ran the simulation it finished with error
image

thank you
Abdul

Thank you

Dear Abdul,

declaring a dynamic array is not enough, you need to ALLOCATE them as well.

Furthermore it seems the x0, x1, y0, y1, z0, and z1 variables don’t have an assigned value, which also can lead to a crash.

Cheers,
David

Dear David,
I see your point and in fact what you pointed out is already written within usrini.f routine. The idea is to compile and link the following user routines, usrini.f, comscw.f, and usrout.f. (in this order) to score KE and LET. Again those routines were function previously and wondering why it’s not working anymore.
please find the attachments so that you can examine the problem.usrini_rt_immun.f (7.1 KB) usrout_rt_immun.f (3.0 KB)

Dear Abdul,

you are missing the line

USE RTIMMUN

in comscw.f. It is needed if you want to access the variables declared the module.

Cheers,
David

Yes I added it before but still outputs error code 2

Dear Abdul,

could you share your Flair project file as well?

Cheers,
David

proton_beam.flair (2.2 KB)

thank you
Abdul

Dear Abdul,

your usrini_rt_immun.f routine is not compatible with FLUKA 4.

You need to change line 37 to:

SUBROUTINE USRINI ( WHAT, SDUM )

line 64 to:

CHARACTER SDUM*8

and remove line 75.

Cheers,
David

Thank you so much sir, problem solved.

sincerely,
Abdul