How to output 'unformatted file'?

From: Hantao Jing <jinght_at_mail.ihep.ac.cn>
Date: Mon, 03 Aug 2009 18:14:07 +0800

Dear FLUKA experts,

       I want to output results in an unformatted file by employing the
USERDUMP card. So I do the following things:
firstly, I defined the USERDUMP card in my input file,
*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
USERDUMP 100.0 0.0 3.0 0.0
;
Then, I add my user-code in the 'mgdraw.f' file,

       ENTRY BXDRAW ( ICODE, MREG, NEWREG, XSCO, YSCO, ZSCO )

       IF (.NOT. LFCOPE) THEN
         LFCOPE = .TRUE.
         OPEN(UNIT=60, FILE = 'Age.60',FORM = 'UNFORMATTED',
      & STATUS = 'NEW')
       END IF

       IF( JTRACK.EQ.1) THEN ! Select protons
         IF(ETRACK.GT.AM(JTRACK)) THEN ! Neutron has survived
           TPPTRACK = ETRACK - AM(JTRACK)
           IF(MREG.EQ.2 .AND. NEWREG.EQ.8) THEN ! Select the desired
boundary

* TPPTRACK is kinetic energy,PTRACK is the momentum; ETRACK, PTRACK AND
* AM(JTRACK) satisfy the mass-energy relation E^2=m^2+p^2;

       WRITE(60,200) XSCO,YSCO,ZSCO,TPPTRACK,WTRACK

           ENDIF

         ENDIF
       ENDIF

   200 format(3F8.3,E15.7,F6.2)

       RETURN
;

When I run the fluka, the error apperars,

[jinght_at_sns022 ~/TailEnd/collimators/NoJaw]$ $TARGET_MACHINE = Linux
$FLUPRO = /home/jinght/fluka
$PEMF = /home/jinght/fluka/libec_thihecufealw_10t.pemf

Initial seed copied from /home/jinght/fluka
Running fluka in /home/jinght/TailEnd/collimators/NoJaw/fluka_5998

======================= Running FLUKA for cycle # 1 =======================

[jinght_at_sns022 ~/TailEnd/collimators/NoJaw]$
/home/jinght/fluka/flutil/rfluka: line 338: 6024 Aborted
   (core dumped) ${EXE} < $INPN 2> $LOGF > $LOGF

[1]+ Exit 134 $FLUPRO/flutil/rfluka -e myfluka -N0 -M1 NoJaw
.

But when I revise the FORM = 'UNFORMATTED' to FORM = 'FORMATTED',
everything is ok. I can obtain the formatted the file. The fluka works well.

My input file and mgdraw.f is in attachment.

Please tell me how to output unformatted file correctly. Thank you in
advance.

                                       Hantao Jing
                                      2009-8-3

* E:\TailEnd\collimators\Geometries\collimatorNoJaw.dat
* Created: 2.8.2009
* At: 15:1:40
TITLE
MC-CAD Test
GLOBAL 1000.0 0.0 0.0 0.0 1.0 0.
* ..+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
BEAM -1.6 0.0 0.0 2.0 0.0 -1.0PROTON
BEAMPOS 0.0 0.0 -60.0
GEOBEGIN
    0 0 MC-CAD
* BH1
  RPP BH1 -10000.00 10000.00 -10000.00 10000.00 -10000.00 10000.00
* CF6
  PLA CF6 0.00000 -0.86603 0.50000 0.000 -1.500 -40.000
* CP1
  XYP CP1 -40.00
* CP10
  PLA CP10 0.00000 -0.86603 -0.50000 0.000 -1.500 40.000
* CP11
  PLA CP11 0.93969 0.00000 0.34202 -4.000 0.000 40.000
* CP12
  PLA CP12 0.93969 0.00000 -0.34202 4.000 0.000 40.000
* CP2
  XYP CP2 40.00
* CP3
  PLA CP3 0.00000 -1.00000 0.00000 0.000 1.500 0.000
* CP4
  PLA CP4 0.00000 -1.00000 0.00000 0.000 -1.500 0.000
* CP5
  PLA CP5 0.00000 -0.86603 -0.50000 0.000 1.500 -40.000
* CP7
  PLA CP7 0.93969 0.00000 0.34202 4.000 0.000 -40.000
* CP8
  PLA CP8 0.93969 0.00000 -0.34202 -4.000 0.000 -40.000
* CP9
  PLA CP9 0.00000 -0.86603 0.50000 0.000 1.500 40.000
* JAW
  RPP JAW -4.00 4.00 -5.50 5.50 -80.00 80.00
* OUT
  RPP OUT -10.00 10.00 -10.00 10.00 -50.00 50.00
* VA1
  RPP VA1 -5000.00 5000.00 -5000.00 5000.00 -5000.00 5000.00
  END
* Reg # 1
* BH; assigned material: Blackhole; mat # (1)
BH 5 +BH1 -VA1
* Reg # 2
* VA; assigned material: Vacuum; mat # (2)
VA 5 +VA1 -OUT
* Reg # 3
* CF2; assigned material: Copper; mat # (12)
CF2 5 + ( +CP2 + ( +OUT -CP1 ) ) -JAW
* Reg # 4
* JAWD; assigned material: Copper; mat # (12)
JAWD 5 + ( +JAW -CP4 -CP1 ) +CP2
* Reg # 5
* JAWU; assigned material: Copper; mat # (12)
JAWU 5 + ( +CP3 +JAW +CP2 ) -CP1
* Reg # 6
* CF1; assigned material: Copper; mat # (12)
CF1 5 + ( + ( +OUT +CP1 ) -CF6 ) | + ( +OUT +CP1 +CP5 ) | + ( + ( +OUT +CP1 +CP8
           +CF6 ) -CP5 ) | + ( + ( +OUT +CP1 +CF6 ) -CP7 -CP5 )
* Reg # 7
* CF3; assigned material: Copper; mat # (12)
CF3 5 + ( + ( +OUT -CP2 ) +CP9 ) | + ( + ( +OUT -CP2 ) -CP10 ) | + ( + ( + ( +OUT -CP2 ) +CP11
           +CP10 ) -CP9 ) | + ( + ( +OUT -CP2 -CP12 -CP9 ) +CP10 )
* Reg # 8
* CFV1; assigned material: Vacuum; mat # (2)
CFV1 5 + ( + ( +OUT +CP1 ) -CP5 -CP8 ) +CF6 +CP7
* Reg # 9
* TUN; assigned material: Vacuum; mat # (2)
TUN 5 + ( + ( + ( +JAW -CP3 ) +CP4 ) -CP1 ) +CP2
* Reg # 10
* CFV3; assigned material: Vacuum; mat # (2)
CFV3 5 + ( +OUT -CP2 -CP9 -CP11 ) +CP10 +CP12
  END
GEOEND
*
ASSIGNMAT 1.0 1
ASSIGNMAT 2.0 2
ASSIGNMAT 12.0 3
ASSIGNMAT 12.0 4
ASSIGNMAT 12.0 5
ASSIGNMAT 12.0 6
ASSIGNMAT 12.0 7
ASSIGNMAT 2.0 8
ASSIGNMAT 2.0 9
ASSIGNMAT 2.0 10
*
*
*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
USERDUMP 100.0 0.0 3.0 0.0
*
* Energy distribution( 1.0D-10 to 0.08 GeV)
* ..+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
USRBDX -1.0 PROTON -50.0 VA CFV1 222.324In1
USRBDX 1.6 1.0D-3 300.0 6.283185 0.0 1.0&
* ..+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
USRBDX -1.0 PROTON -50.0 CFV1 TUN 24.0In2
USRBDX 1.6 1.0D-3 300.0 6.283185 0.0 1.0&
* ..+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
USRBDX -1.0 BEAMPART -50.0 CFV1 TUN 24.0In3
USRBDX 1.6 1.0D-3 300.0 6.283185 0.0 1.0&
*
* ..+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
USRBDX 2.0 PROTON -50.0 CFV3 VA 222.324Out1
USRBDX 1.6 1.0D-3 300.0 6.283185 0.0 1.0&
* ..+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
USRBDX 2.0 PROTON -50.0 TUN CFV3 24.0Out2
USRBDX 1.6 1.0D-3 300.0 6.283185 0.0 1.0&
* ..+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
USRBDX 2.0 BEAMPART -50.0 TUN CFV3 24.0Out3
USRBDX 1.6 1.0D-3 300.0 6.283185 0.0 1.0&
*
*
* ..+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
RANDOMIZ 1.0
* ..+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
START 100000.0
*USROCALL
STOP

*$ CREATE MGDRAW.FOR
*COPY MGDRAW
* *
*=== mgdraw ===========================================================*
* *
      SUBROUTINE MGDRAW ( ICODE, MREG )

      INCLUDE '(DBLPRC)'
      INCLUDE '(DIMPAR)'
      INCLUDE '(IOUNIT)'
*
*----------------------------------------------------------------------*
* *
* Copyright (C) 1990-2006 by Alfredo Ferrari *
* All Rights Reserved. *
* *
* *
* MaGnetic field trajectory DRAWing: actually this entry manages *
* all trajectory dumping for *
* drawing *
* *
* Created on 01 march 1990 by Alfredo Ferrari *
* INFN - Milan *
* Last change 05-may-06 by Alfredo Ferrari *
* INFN - Milan *
* *
*----------------------------------------------------------------------*
*
      INCLUDE '(CASLIM)'
      INCLUDE '(COMPUT)'
      INCLUDE '(SOURCM)'
      INCLUDE '(FHEAVY)'
      INCLUDE '(FLKSTK)'
      INCLUDE '(GENSTK)'
      INCLUDE '(MGDDCM)'
      INCLUDE '(PAPROP)'
      INCLUDE '(QUEMGD)'
      INCLUDE '(SUMCOU)'
      INCLUDE '(TRACKR)'
*
      DIMENSION DTQUEN ( MXTRCK, MAXQMG )
*
      CHARACTER*20 FILNAM
      LOGICAL LFCOPE
      SAVE LFCOPE
      DATA LFCOPE / .FALSE. /
*
*----------------------------------------------------------------------*
* *
* Icode = 1: call from Kaskad *
* Icode = 2: call from Emfsco *
* Icode = 3: call from Kasneu *
* Icode = 4: call from Kashea *
* Icode = 5: call from Kasoph *
* *
*----------------------------------------------------------------------*
* *
c IF ( .NOT. LFCOPE ) THEN
c LFCOPE = .TRUE.
c IF ( KOMPUT .EQ. 2 ) THEN
c FILNAM = '/'//CFDRAW(1:8)//' DUMP A'
c ELSE
c FILNAM = CFDRAW
c END IF
c OPEN ( UNIT = IODRAW, FILE = FILNAM, STATUS = 'NEW', FORM =
c & 'UNFORMATTED' )
c END IF
c WRITE (IODRAW) NTRACK, MTRACK, JTRACK, SNGL (ETRACK),
c & SNGL (WTRACK)
c WRITE (IODRAW) ( SNGL (XTRACK (I)), SNGL (YTRACK (I)),
c & SNGL (ZTRACK (I)), I = 0, NTRACK ),
c & ( SNGL (DTRACK (I)), I = 1, MTRACK ),
c & SNGL (CTRACK)
* +-------------------------------------------------------------------*
* | Quenching is activated
c IF ( LQEMGD ) THEN
c IF ( MTRACK .GT. 0 ) THEN
c RULLL = ZERZER
c CALL QUENMG ( ICODE, MREG, RULLL, DTQUEN )
c WRITE (IODRAW) ( ( SNGL (DTQUEN (I,JBK)), I = 1, MTRACK ),
c & JBK = 1, NQEMGD )
c END IF
c END IF
* | End of quenching
* +-------------------------------------------------------------------*
      RETURN
*
*======================================================================*
* *
* Boundary-(X)crossing DRAWing: *
* *
* Icode = 1x: call from Kaskad *
* 19: boundary crossing *
* Icode = 2x: call from Emfsco *
* 29: boundary crossing *
* Icode = 3x: call from Kasneu *
* 39: boundary crossing *
* Icode = 4x: call from Kashea *
* 49: boundary crossing *
* Icode = 5x: call from Kasoph *
* 59: boundary crossing *
* *
*======================================================================*
* *
      ENTRY BXDRAW ( ICODE, MREG, NEWREG, XSCO, YSCO, ZSCO )
      
      IF (.NOT. LFCOPE) THEN
        LFCOPE = .TRUE.
        OPEN(UNIT=60, FILE = 'Age.60',FORM = 'UNFORMATTED',
     & STATUS = 'NEW')
      END IF

      IF( JTRACK.EQ.1) THEN ! Select protons
        IF(ETRACK.GT.AM(JTRACK)) THEN ! Neutron has survived
          TPPTRACK = ETRACK - AM(JTRACK)
          IF(MREG.EQ.2 .AND. NEWREG.EQ.8) THEN ! Select the desired boundary

* TPPTRACK is kinetic energy,PTRACK is the momentum; ETRACK, PTRACK AND
* AM(JTRACK) satisfy the mass-energy relation E^2=m^2+p^2;

 
      WRITE(60,200) XSCO,YSCO,ZSCO,TPPTRACK,WTRACK

            
          ENDIF

        ENDIF
      ENDIF

  200 format(3F8.3,E15.7,F6.2)

      RETURN
*
*======================================================================*
* *
* Event End DRAWing: *
* *
*======================================================================*
* *
      ENTRY EEDRAW ( ICODE )
      RETURN
*
*======================================================================*
* *
* ENergy deposition DRAWing: *
* *
* Icode = 1x: call from Kaskad *
* 10: elastic interaction recoil *
* 11: inelastic interaction recoil *
* 12: stopping particle *
* 13: pseudo-neutron deposition *
* 14: escape *
* 15: time kill *
* Icode = 2x: call from Emfsco *
* 20: local energy deposition (i.e. photoelectric) *
* 21: below threshold, iarg=1 *
* 22: below threshold, iarg=2 *
* 23: escape *
* 24: time kill *
* Icode = 3x: call from Kasneu *
* 30: target recoil *
* 31: below threshold *
* 32: escape *
* 33: time kill *
* Icode = 4x: call from Kashea *
* 40: escape *
* 41: time kill *
* 42: delta ray stack overflow *
* Icode = 5x: call from Kasoph *
* 50: optical photon absorption *
* 51: escape *
* 52: time kill *
* *
*======================================================================*
* *
      ENTRY ENDRAW ( ICODE, MREG, RULL, XSCO, YSCO, ZSCO )
c IF ( .NOT. LFCOPE ) THEN
c LFCOPE = .TRUE.
c IF ( KOMPUT .EQ. 2 ) THEN
c FILNAM = '/'//CFDRAW(1:8)//' DUMP A'
c ELSE
c FILNAM = CFDRAW
c END IF
c OPEN ( UNIT = IODRAW, FILE = FILNAM, STATUS = 'NEW', FORM =
c & 'UNFORMATTED' )
c END IF
c WRITE (IODRAW) 0, ICODE, JTRACK, SNGL (ETRACK), SNGL (WTRACK)
c WRITE (IODRAW) SNGL (XSCO), SNGL (YSCO), SNGL (ZSCO), SNGL (RULL)
* +-------------------------------------------------------------------*
* | Quenching is activated : calculate quenching factor
* | and store quenched energy in DTQUEN(1, jbk)
c IF ( LQEMGD ) THEN
c RULLL = RULL
c CALL QUENMG ( ICODE, MREG, RULLL, DTQUEN )
c WRITE (IODRAW) ( SNGL (DTQUEN(1, JBK)), JBK = 1, NQEMGD )
c END IF
* | end quenching
* +-------------------------------------------------------------------*
      RETURN
*
*======================================================================*
* *
* SOurce particle DRAWing: *
* *
*======================================================================*
*
      ENTRY SODRAW
c IF ( .NOT. LFCOPE ) THEN
c LFCOPE = .TRUE.
c IF ( KOMPUT .EQ. 2 ) THEN
c FILNAM = '/'//CFDRAW(1:8)//' DUMP A'
c ELSE
c FILNAM = CFDRAW
c END IF
c OPEN ( UNIT = IODRAW, FILE = FILNAM, STATUS = 'NEW', FORM =
c & 'UNFORMATTED' )
c END IF
c WRITE (IODRAW) -NCASE, NPFLKA, NSTMAX, SNGL (TKESUM),
c & SNGL (WEIPRI)
* +-------------------------------------------------------------------*
* | (Radioactive) isotope: it works only for 1 source particle on
* | the stack for the time being
c IF ( ILOFLK (NPFLKA) .GE. 100000 .AND. LRADDC (NPFLKA) ) THEN
c IARES = MOD ( ILOFLK (NPFLKA), 100000 ) / 100
c IZRES = MOD ( ILOFLK (NPFLKA), 10000000 ) / 100000
c IISRES = ILOFLK (NPFLKA) / 10000000
c IONID = ILOFLK (NPFLKA)
c WRITE (IODRAW) ( IONID,SNGL(-TKEFLK(I)),
c & SNGL (WTFLK(I)), SNGL (XFLK (I)),
c & SNGL (YFLK (I)), SNGL (ZFLK (I)),
c & SNGL (TXFLK(I)), SNGL (TYFLK(I)),
c & SNGL (TZFLK(I)), I = 1, NPFLKA )
* |
* +-------------------------------------------------------------------*
* | Patch for heavy ions: it works only for 1 source particle on
* | the stack for the time being
c ELSE IF ( ABS (ILOFLK (NPFLKA)) .GE. 10000 ) THEN
c IONID = ILOFLK (NPFLKA)
c CALL DCDION ( IONID )
c WRITE (IODRAW) ( IONID,SNGL(TKEFLK(I)+AMNHEA(-IONID)),
c & SNGL (WTFLK(I)), SNGL (XFLK (I)),
c & SNGL (YFLK (I)), SNGL (ZFLK (I)),
c & SNGL (TXFLK(I)), SNGL (TYFLK(I)),
c & SNGL (TZFLK(I)), I = 1, NPFLKA )
* |
* +-------------------------------------------------------------------*
* | Patch for heavy ions: ???
c ELSE IF ( ILOFLK (NPFLKA) .LT. -6 ) THEN
c WRITE (IODRAW) ( IONID,SNGL(TKEFLK(I)+AMNHEA(-ILOFLK(NPFLKA))),
c & SNGL (WTFLK(I)), SNGL (XFLK (I)),
c & SNGL (YFLK (I)), SNGL (ZFLK (I)),
c & SNGL (TXFLK(I)), SNGL (TYFLK(I)),
c & SNGL (TZFLK(I)), I = 1, NPFLKA )
* |
* +-------------------------------------------------------------------*
* |
c ELSE
c WRITE (IODRAW) ( ILOFLK(I), SNGL (TKEFLK(I)+AM(ILOFLK(I))),
c & SNGL (WTFLK(I)), SNGL (XFLK (I)),
c & SNGL (YFLK (I)), SNGL (ZFLK (I)),
c & SNGL (TXFLK(I)), SNGL (TYFLK(I)),
c & SNGL (TZFLK(I)), I = 1, NPFLKA )
c END IF
* |
* +-------------------------------------------------------------------*
      RETURN
*
*======================================================================*
* *
* USer dependent DRAWing: *
* *
* Icode = 10x: call from Kaskad *
* 100: elastic interaction secondaries *
* 101: inelastic interaction secondaries *
* 102: particle decay secondaries *
* 103: delta ray generation secondaries *
* 104: pair production secondaries *
* 105: bremsstrahlung secondaries *
* 110: decay products *
* Icode = 20x: call from Emfsco *
* 208: bremsstrahlung secondaries *
* 210: Moller secondaries *
* 212: Bhabha secondaries *
* 214: in-flight annihilation secondaries *
* 215: annihilation at rest secondaries *
* 217: pair production secondaries *
* 219: Compton scattering secondaries *
* 221: photoelectric secondaries *
* 225: Rayleigh scattering secondaries *
* Icode = 30x: call from Kasneu *
* 300: interaction secondaries *
* Icode = 40x: call from Kashea *
* 400: delta ray generation secondaries *
* For all interactions secondaries are put on GENSTK common (kp=1,np) *
* but for KASHEA delta ray generation where only the secondary elec- *
* tron is present and stacked on FLKSTK common for kp=npflka *
* *
*======================================================================*
*
      ENTRY USDRAW ( ICODE, MREG, XSCO, YSCO, ZSCO )
c IF ( .NOT. LFCOPE ) THEN
c LFCOPE = .TRUE.
c IF ( KOMPUT .EQ. 2 ) THEN
c FILNAM = '/'//CFDRAW(1:8)//' DUMP A'
c ELSE
c FILNAM = CFDRAW
c END IF
c OPEN ( UNIT = IODRAW, FILE = FILNAM, STATUS = 'NEW', FORM =
c & 'UNFORMATTED' )
c END IF
* No output by default:
      RETURN
*=== End of subrutine Mgdraw ==========================================*
      END
Received on Mon Aug 03 2009 - 13:18:39 CEST

This archive was generated by hypermail 2.2.0 : Mon Aug 03 2009 - 13:18:43 CEST