mgdrawBDX for scoring both photons and electrons

Dear Expert,

I want to score the position, energy, weight and direction for both photons and electrons using a single mgdrawBDX.f . But I am getting an error while compiling. Can you please guide me about the mistake?

mgdrawBDX.f (3.7 KB)

Regards,
Riya

Hi @riya
either you write

     IF(JTRACK .EQ. 7)  THEN
        WRITE(88,'(1P,8G25.15)') 
&      XSCO, YSCO, ZSCO, ETRACK, WTRACK,CXTRCK, CYTRCK, CZTRCK
     ELSE IF(JTRACK .EQ. 3) THEN
        WRITE(98,'(1P,8G25.15)') 
&      XSCO, YSCO, ZSCO, ETRACK, WTRACK,CXTRCK, CYTRCK, CZTRCK
     END IF

(which is preferable) or

     IF(JTRACK .EQ. 7)  WRITE(88,'(1P,8G25.15)') 
&      XSCO, YSCO, ZSCO, ETRACK, WTRACK,CXTRCK, CYTRCK, CZTRCK
     IF(JTRACK .EQ. 3) WRITE(98,'(1P,8G25.15)') 
&      XSCO, YSCO, ZSCO, ETRACK, WTRACK,CXTRCK, CYTRCK, CZTRCK

(the first version is an IF structure, the second features two independent IF statements, where ELSE IF cannot sit).

Also, do not call GEOR2N every time (which is inefficient), rather the complementary routine GEON2R

     CALL GEON2R ( 'VOID    ', NUPREG, IERR ) ! find upstream region number
     CALL GEON2R ( 'VRTUCY  ', NDOREG, IERR ) ! find downstream region number

only once, e.g. together with the OPEN statements under the condition

  IF ( .NOT. LFCOPE ) THEN

and save the NUPREG and NDOREG integer variables to compare runtime MREG and NEWREG with.

1 Like

Thank you @ceruttif for the help.

  1. Two independent IF structure worked; Initially, I tried using IF - THEN - ELSE IF - END IF, but I got errors saying ENTRY statement cannot appear within an IF-THEN block.

  2. I have removed calling GEOR2N. Also I have removed the line IF(IERR1 .NE. 0 .OR. IERR2 .NE. 0) STOP “Error in name conversion”. It is not necessary, right ?

Here is the modified mgdrawBDX file.

mgdrawBDX.f (3.8 KB)

Regards,
Riya

The IF-THEN/ELSEIF-THEN/ENDIF structure perfectly works as well. If it did not, there was some basic syntax error.

This you may want rather to keep it as a sanity check. Of course it requires that in the GEON2R calls you replace IERR by IERR1 and IERR2.

The GEON2R calls should be inside the IF ( .NOT. LFCOPE ) THEN block (this is what I meant with under the condition), otherwise they are invoked every time and not only once.
More importantly, the condition

  IF(MRGNAM .EQ. "VOID" .AND. nrgnam .EQ. "VRTUCY") THEN

makes no sense anymore (you keep comparing region names, although now MRGNAM and NRGNAM are no longer defined, instead of comparing region numbers after decoding the names once forever). It should read

  IF(MREG .EQ. NUPREG .AND. NEWREG .EQ. NDOREG) THEN
1 Like

Thank you @ceruttif

Regards,
Riya