C
C October 2012:
C Top-level pre-processor commands to include psnid and snana fortran codes.
C Psnid-dependent C code (psnid_BEST.c, psnid_toos.c[h]) is included in the 
C Makefile link.
C


+NAMES,8,6000,48000.
+USE,LINUX.
+USE,PSNID.

c Patch in the main snana program and common blocks to read data and apply cuts
+USE,P=*SNCOM.
c +USE,P=*SNMAIN,T=EXE.
+USE,P=*SNANA,T=EXE.
+PAM,LUN=10, T=A,C. snana.lnk

c patch in code for lc plots with best-fit model (same as in snlc_fit)
+USE,P=*FITCOM.  
+USE,P=*PLOTPREP,T=EXE.
+PAM,LUN=20, T=A,C. snlc_fit.lnk

c patch in PSNID control-code below (psnid.car -> psnid.lnk during compilation)
+USE,P=*PIDCOM.
+USE,P=*PIDCODE,T=EXE.
+PAM,LUN=30, T=A,C. psnid.lnk

c patch in user code
+USE,P=*USRCOM.
+USE,P=*USRCODE,T=EXE.


C ###############################
+PATCH,*USRCOM.
C ###############################

c Put your private common blocks here.
+KEEP,MYCOM.
      REAL MYFLOAT
      COMMON / MYCOM / MYFLOAT


C ###############################
+PATCH,*USRCODE.
C ###############################


C ===========================================
+DECK,USRINI.
      SUBROUTINE USRINI(IERR)
c
c User init-routine called once aftet SN are read in,
c but before they are analyzed.
c -------------------------------------
      IMPLICIT NONE
      INTEGER IERR ! (O) 0 => OK
c local var
      INTEGER LL
C ------------------- BEGIN ---------------------
      IERR = 0
      RETURN
      END

C ===========================================
+DECK,USRINI2.
      SUBROUTINE USRINI2(IERR)
      IMPLICIT NONE
      INTEGER IERR
      IERR = 0
      RETURN
      END

C ===========================================
+DECK,USRCUTS.
      SUBROUTINE USRCUTS(IERR)

c -------------------------------------
      IMPLICIT NONE
c declare subroutine args
      INTEGER IERR ! (O) 0 => OK
C ------------------- BEGIN ---------------------
      IERR = 0
      RETURN
      END

C ===========================================
+DECK,USRANA.
      SUBROUTINE USRANA(IERR)
c
c User analysis routine for each Supernova
c See SNLC_XXX varibales in 
c      $SNANA_DIR/src/snana.car
c
c -------------------------------------
      IMPLICIT NONE
c +CDE,SNDATCOM. 
c declare subroutine args
      INTEGER IERR ! (O) 0 => OK
C ------------------- BEGIN ---------------------
      IERR = 0
      RETURN
      END

C ===========================================
+DECK,USREND.
      SUBROUTINE USREND(IERR)
c
c User end-routine after all analysis/fits are done. 
c [close files, summarize statistics, global analysis, etc ...]
c -------------------------------------
      IMPLICIT NONE
      INTEGER IERR ! (O) 0 => OK
c local var
      INTEGER LL
C ------------------- BEGIN ---------------------
      IERR = 0
      RETURN
      END

 