text stringlengths 9 3.83M |
|---|
subroutine errors
c *****************
c
include'com'
c
double precision pl(KK+1,KK+1)
double precision exact(KK+1)
double precision apprx(KK+1)
double precision errrr(KK+1)
c
c --- computing the Gaussian points
kgauss=k+4
call gauleg(-1.d00,1.d00,x,w,kgauss)
c
c evaluating the Legendre polynomials at
c the quadrature points
do i=1,kgauss
pl(i,1)=1.d00
pl(i,2)=x(i)
do j=2,k
pl(i,j+1)=((2.d00*j-1.d00)*x(i)*pl(i,j)
* -(j-1.d00)*pl(i,j-1))/j
enddo
enddo
c
c --- computation of the L-infinity and L1-errors
c
c --- initialization
errl1(ne)=0.d00
errli(ne)=0.d00
c
c --- loop on the elements
do i=1, nx
c
c the midpoint of the element
xic=(2.d00*i-1.d00)*dx/2.d00
c
c evaluating the errors at the quadrature points
do m=1,kgauss
exact(m)=func(xic+x(m)*dx/2.d00,t)
apprx(m)=0.d00
do j=1,k+1
apprx(m)=apprx(m)+u(i,j,0)*pl(m,j)
enddo
errrr(m)=abs(exact(m)-apprx(m))
enddo
c
c --- the errors
c L1:
aux=0.d00
do m=1,kgauss
aux=aux+errrr(m)*w(m)
enddo
c errl1(ne)=errl1(ne)+aux
errl1(ne)=errl1(ne)+aux**2
c
c L-infinity:
do m=1,kgauss
if (errrr(m).gt.errli(ne)) errli(ne)=errrr(m)
enddo
c
enddo
c
errl1(ne)=sqrt(ddx(ne)*errl1(ne))
c
end
|
C
C $Id: tdmtri.f,v 1.4 2008-07-27 00:17:33 haley Exp $
C
C Copyright (C) 2000
C University Corporation for Atmospheric Research
C All Rights Reserved
C
C The use of this Software is governed by a License Agreement.
C
SUBROUTINE TDMTRI (IMRK,UMRK,VMRK,WMRK,SMRK,RTRI,MTRI,NTRI,IRST,
+ UMIN,VMIN,WMIN,UMAX,VMAX,WMAX)
C
DIMENSION RTRI(10,MTRI)
C
C This routine is called to put a marker of type ABS(IMRK) at the point
C with coordinates (UMRK,VMRK,WMRK) and with radius SMRK. This is done
C by adding triangles to the triangle list in the array RTRI. MTRI is
C the maximum number of triangles that can be put in the list and NTRI
C is the number of triangles currently in the list. IRST is the index
C of the rendering style to be used for the marker.
C
C IMRK may have an absolute value from 1 to 5, inclusive, to select a
C tetrahedron, an octahedron, a cube, an icosahedron, or an elaborated
C icosahedron (effectively, a sphere), respectively. If IMRK is less
C than zero, the mark is not clipped at the faces of the box defined
C by the last six arguments; otherwise, it is.
C
IF (IMRK.LT.0) THEN
CALL TDMRKA (-IMRK,UMRK,VMRK,WMRK,SMRK,RTRI,MTRI,NTRI,IRST)
ELSE
CALL TDMRKB ( IMRK,UMRK,VMRK,WMRK,SMRK,RTRI,MTRI,NTRI,IRST,
+ UMIN,VMIN,WMIN,UMAX,VMAX,WMAX)
END IF
C
C Done.
C
RETURN
C
END
|
INTEGER GETARG,GETLIN,OPEN
INTEGER I,FILE
INTEGER OUTCH,LINE(102)
FILE=-10
IF((GETARG(1,LINE,102).EQ.-1))GOTO 10000
FILE=OPEN(LINE,1)
IF((FILE.NE.-3))GOTO 10001
CALL CANT(LINE)
10001 CONTINUE
10000 CONTINUE
10002 IF((GETLIN(LINE,FILE).EQ.-1))GOTO 10003
I=1
GOTO 10006
10004 I=I+(1)
10006 IF((LINE(I).EQ.160))GOTO 10005
GOTO 10004
10005 CONTINUE
10007 I=I+(1)
OUTCH=0
GOTO 10010
10008 I=I+(1)
10010 IF(((LINE(I).EQ.160).OR.(LINE(I).EQ.138)))GOTO 10009
OUTCH=8*OUTCH+LINE(I)-176
GOTO 10008
10009 CALL T1OU(OUTCH)
IF((LINE(I).NE.138))GOTO 10007
GOTO 10002
10003 CALL CLOSE(FILE)
CALL SWT
END
C ---- Long Name Map ----
|
* vert_his1_squ1.F
* this file is part of the process {MNE1, MNE1} -> {0, MZ}
* generated by WriteSquaredME 7 Oct 2009 9:58
subroutine gzvert_his1_squ1
implicit character (a-s,u-z)
implicit double complex (t)
#include "vars.h"
Cloop(1) = Cloop(1) +
- (Cval(cc00,iint44(squ1))*
- (1/(72.D0*Pi**2)*
- (Abb10*EE*MTR032(his1,squ1)*MTR052(squ1)*
- MTR136(1,1,his1)) +
- 1/(72.D0*Pi**2)*
- (Abb7*EE*MTR032(his1,squ1)*MTR052(squ1)*
- MTR137(1,1,his1))) +
- Cval(cc12,iint44(squ1))*
- (-(1/(72.D0*Pi**2)*
- (AbbSum63*EE*MTR032(his1,squ1)*MTR052(squ1)*
- MTR136(1,1,his1))) -
- 1/(72.D0*Pi**2)*
- (AbbSum62*EE*MTR032(his1,squ1)*MTR052(squ1)*
- MTR137(1,1,his1))) +
- (Cval(cc00,iint45(squ1)) + Cval(cc00,iint46(squ1)))*
- (-(1/(24.D0*Pi**2)*
- (Abb10*EE*MTR033(his1,squ1)*MTR053(squ1)*
- MTR136(1,1,his1))) -
- 1/(24.D0*Pi**2)*
- (Abb7*EE*MTR033(his1,squ1)*MTR053(squ1)*
- MTR137(1,1,his1))) +
- (Cval(cc12,iint45(squ1)) + Cval(cc12,iint46(squ1)))*
- (1/(24.D0*Pi**2)*
- (AbbSum63*EE*MTR033(his1,squ1)*MTR053(squ1)*
- MTR136(1,1,his1)) +
- 1/(24.D0*Pi**2)*
- (AbbSum62*EE*MTR033(his1,squ1)*MTR053(squ1)*
- MTR137(1,1,his1))) +
- cint28(squ1)*(-(1/(288.D0*Pi**2)*
- (Abb10*MTR032(his1,squ1)*MTR136(1,1,his1)*
- MTR414(squ1))) -
- 1/(288.D0*Pi**2)*
- (Abb7*MTR032(his1,squ1)*MTR137(1,1,his1)*
- MTR414(squ1))) +
- cint46(squ1)*(1/(48.D0*Pi**2)*
- (Abb10*MTR033(his1,squ1)*MTR136(1,1,his1)*
- MTR418(squ1)) +
- 1/(48.D0*Pi**2)*
- (Abb7*MTR033(his1,squ1)*MTR137(1,1,his1)*
- MTR418(squ1))))/(S - hisMass(his1)**2)
end
|
C MODULE JULDA
C-----------------------------------------------------------------------
C ROUTINE JULDA CONVERTS FROM MONTH, DAY, YEAR, HOUR FOR A SPECIFIED
C TIME ZONE TO INTERNAL CLOCK TIME
C (JULIAN DAY RELATIVE TO JAN 1, 1900)
C-----------------------------------------------------------------------
SUBROUTINE JULDA (JDAY,INTHR,M,D,Y,H,ITZ,IDSAV,CODE)
EXTERNAL DDYCDL,DDGCDM,DDGCD2,WARN
INTEGER D,Y,H,CODE
INCLUDE 'common/ionum'
INCLUDE 'common/fdbug'
INCLUDE 'common/fctime'
C
C ================================= RCS keyword statements ==========
CHARACTER*68 RCSKW1,RCSKW2
DATA RCSKW1,RCSKW2 / '
.$Source: /fs/hseb/ob72/rfc/ofs/src/shared_util/RCS/julda.f,v $
. $', '
.$Id: julda.f,v 1.1 1998/07/02 20:04:15 page Exp $
. $' /
C ===================================================================
C
C J1 IS JULIAN DAY OF DEC 31,1899
DATA INTL / 4hINTL /
IF (ITRACE.GT.2) WRITE (IODBUG,*) ' **JULDA ENTERED'
C CAN ONLY CONVERT TO INTERNAL TIME WHEN NLSTZ IS DEFINED
IF ( (NLSTZ.LT.-12 .OR. NLSTZ.GT.12) .AND.
* (ITZ.GE.-12 .AND. ITZ.LE.12 ) ) THEN
WRITE (IPR,40) CODE
40 FORMAT (1H0,10X,'**WARNING** JULDA UNABLE TO CONVERT ',
* 'FROM INTERMAL TIME TO REQUESTED TIME ZONE ',A4,' BECAUSE' /
* 11X,'VARIABLE NLSTZ IN COMMON BLOCK FCTIME IS OUTSIDE ',
* 'THE RANGE -12 TO 12.')
CALL WARN()
ITZ=100
IDSAV=0
CODE=INTL
ENDIF
C REPLACE ARGUMENTS M,D,Y,H WITH IM,ID,IY, AND IH
IY=Y
IM=M
ID=D
IH=H
IF (IM.LT.1) IM=1
IF (IM.GT.12) IM=12
IF (ID.LT.1) ID=1
C Make sure the year is four digits using the 90/10 year rule
C Get number of days in month, NODIM
CALL DDYCDL(IY,IM,ID)
CALL DDGCDM(IY,IM,NODIM)
IF (ID.GT.NODIM) ID=NODIM
IF (IH.GT.24) IH=24
IF (IH.LT.0) IH=0
C COMPUTE JULIAN DAY
CALL DDGCD2(JDAY,IY,IM,ID)
C CONVERT IH TO INTERNAL TIME
C IH IS IN TIME ZONE ITZ
C INTERNAL CLOCK IS IN TIME ZONE (NLSTZ-LOCAL)
C TIME ZONE DIFFERENCE BETWEEN THEM IS (NLSTZ-LOCAL)-ITZ
C THEREFORE INTHR=IH+TIME ZONE DIFFERENCE
C =IH+NLSTZ-LOCAL-ITZ
C FOR EXAMPLE, PROCESSED DATA FILE HOUR 1 IS 13Z
C IN EST TIME ZONE, NLSTZ=-5
C AND 8 AM EST IS HOUR 1 OF THE INTERNAL CLOCK
C SO LOCAL=7
C (NLSTZ-LOCAL)=-12 FOR THIS CASE WHICH IS THE TIME
C ZONE NUMBER OF THE TIME ZONE WHERE 13Z
C IS 1 O'CLOCK AM
INTHR=IH
IF (ITZ.GE.-12 .AND. ITZ.LE.12) THEN
INTHR=IH+NLSTZ-LOCAL-ITZ
C DAYLIGHT SAVINGS TIME CORRECTION
IF (IDSAV.EQ.1) INTHR=INTHR-1
ENDIF
C DAY CORRECTION TO PUT INTHR IN THE RANGE 1-24
NDOFF=(INTHR-24)/24
IF (INTHR.GT.0) NDOFF=INTHR/24
IF (NDOFF.GT.0.AND.MOD(INTHR,24).EQ.0) NDOFF=NDOFF-1
JDAY=JDAY+NDOFF
INTHR=INTHR-NDOFF*24
C CHECK IF ARGUMENTS WERE OUT OF RANGE AND RETURN
IF (M.EQ.IM.AND.D.EQ.ID.AND.Y.EQ.IY.AND.H.EQ.IH) GO TO 80
IF (M.EQ.IM.AND.D.EQ.ID.AND.IY-Y.EQ.1900.AND.H.EQ.IH) GO TO 80
IF (M.EQ.IM.AND.D.EQ.ID.AND.IY-Y.EQ.2000.AND.H.EQ.IH) GO TO 80
WRITE (IPR,70) M,D,Y,H,IM,ID,IY,IH
70 FORMAT (1H0,10X,'**WARNING** JULDA CALLED WITH ',
* 'ARGUMENTS OUT OF RANGE WERE RESET TO INDICATED VALUES.' /
* 1H ,20X,5X,5HMONTH,7X,3HDAY,6X,4HYEAR,6X,4HHOUR /
* 1H ,11X,9HAS CALLED,4I10/
* 1H ,11X,9HRESET TO ,4I10/)
CALL WARN()
80 IF (ITRACE.GT.2) WRITE (IODBUG,*) ' **EXIT JULDA'
RETURN
END
|
C MEMBER FSAV2
C (from old member FCEX2)
C
SUBROUTINE FSAV2(K,PO,CO,C,RO)
C.......................................................................
C THIS SUBROUTINE COMPUTES THE RUNOFF TO BE SAVED AS CARRYOVER.
C.......................................................................
C SUBROUTINE INITIALLY WRITTEN BY
C LARRY BRAZIL -- HRL JANUARY 1980 VERSION 1
C.......................................................................
DIMENSION CO(1),C(1),RO(1),PO(1)
C
COMMON/FDBUG/IODBUG,ITRACE,IDBALL,NDEBUG,IDEBUG(20)
COMMON/FCTIME/IDARUN,IHRRUN,LDARUN,LHRRUN,LDACPD,LHRCPD,
1NOW(5),LOCAL,NOUTZ,NOUTDS,NLSTZ,IDA,IHR,LDA,LHR,IDADAT
C
C ================================= RCS keyword statements ==========
CHARACTER*68 RCSKW1,RCSKW2
DATA RCSKW1,RCSKW2 / '
.$Source: /fs/hseb/ob72/rfc/ofs/src/fcst_ex/RCS/fsav2.f,v $
. $', '
.$Id: fsav2.f,v 1.1 1995/09/17 18:58:14 dws Exp $
. $' /
C ===================================================================
C
C.......................................................................
C CHECK TRACE LEVEL -- TRACE LEVEL FOR THIS SUBROUTINE=1.
IF(ITRACE.GE.1) WRITE(IODBUG,900)
900 FORMAT(1H0,16H** FSAV2 ENTERED)
C.......................................................................
C
C CHECK TO SEE IF RO'S TO BE SAVED ARE PRIOR TO IDA & IHR
NRO=PO(21)
IDTR=PO(16)
KRO=K-NRO+1
KIQT=(IDA-IDADAT)*24/IDTR+IHR/IDTR
IF(KRO.GE.KIQT) GO TO 500
KDIFF=KIQT-KRO
DO 400 J=1,KDIFF
L=NRO+1-J
I=KDIFF+1-J
C(I)=CO(L)
400 CONTINUE
KDIFF=KDIFF+1
GO TO 510
500 KDIFF=1
510 DO 410 I=KDIFF,NRO
L=K-NRO+I
C(I)=RO(L)
410 CONTINUE
RETURN
END
|
module Svc {
@ Scheduler Port with order argument
port Sched(
context: NATIVE_UINT_TYPE @< The call order
)
}
|
************************************************************************
*
* Subroutine INPUTH2 Called by: INIT2
*
* input SBEG and SEND
*
************************************************************************
SUBROUTINE INPUTH2(SBEG,SEND,NSEAS)
*
* logical devices
*
INCLUDE 'lda.inc'
*
* subroutine arguments
*
INTEGER*4 NSEAS
CHARACTER*4 SBEG(*),SEND(*)
*
* local vars
*
INTEGER*4 I
CHARACTER*500 BUFFER
*
* output format statement
*
2000 FORMAT(1X,I3,T20,A4,T41,A4)
*
* If seasonal loads are requested (NSEAS > 0), read the the
* begin and end dates (SBEG, SEND) for each season and output.
*
DO 10 I=1,NSEAS
CALL GETLINE(LDHEAD,BUFFER)
READ (BUFFER,*) SBEG(I),SEND(I)
WRITE(LDECHO,2000) I,SBEG(I),SEND(I)
10 CONTINUE
RETURN
END
|
!------------------------------------------------------------------------------
! Harvard University Atmospheric Chemistry Modeling Group !
!------------------------------------------------------------------------------
!BOP
!
! !MODULE: diag49_mod
!
! !DESCRIPTION: Module DIAG49\_MOD contains variables and routines to save
! out 3-D instantaneous timeseries output to disk.
!\\
!\\
! !INTERFACE:
!
MODULE DIAG49_MOD
!
! !USES:
!
IMPLICIT NONE
PRIVATE
!
! !PUBLIC DATA MEMBERS:
!
LOGICAL, PUBLIC :: DO_SAVE_DIAG49
!
! !PUBLIC MEMBER FUNCTIONS:
!
PUBLIC :: DIAG49
PUBLIC :: ITS_TIME_FOR_DIAG49
PUBLIC :: INIT_DIAG49
!
! !PRIVATE MEMBER FUNCTIONS:
!
PRIVATE :: ITS_TIME_TO_CLOSE_FILE
PRIVATE :: GET_I
!
! !REMARKS:
! ND49 tracer numbers:
! ============================================================================
! 1 - N_TRACERS : GEOS-CHEM transported tracers [v/v ]
!
!
! !PRIVATE TYPES:
!
!=================================================================
! MODULE VARIABLES
!
! I0 : Offset between global & nested grid
! J0 : Offset between global & nested grid
! IOFF : Longitude offset
! JOFF : Latitude offset
! LOFF : Altitude offset
! ND49_IMIN : Minimum latitude index for DIAG51 region
! ND49_IMAX : Maximum latitude index for DIAG51 region
! ND49_JMIN : Minimum longitude index for DIAG51 region
! ND49_JMAX : Maximum longitude index for DIAG51 region
! ND49_LMIN : Minimum altitude index for DIAG51 region
! ND49_LMAX : Minimum latitude index for DIAG51 region
! ND49_NI : Number of longitudes in DIAG51 region
! ND49_NJ : Number of latitudes in DIAG51 region
! ND49_NL : Number of levels in DIAG51 region
! ND49_N_TRACERS : Number of tracers for DIAG51
! ND49_OUTPUT_FILE : Name of bpch file w timeseries data
! ND49_TRACERS : Array of DIAG51 tracer numbers
! HALFPOLAR : Used for bpch file output
! CENTER180 : Used for bpch file output
! LONRES : Used for bpch file output
! LATRES : Used for bpch file output
! MODELNAME : Used for bpch file output
! RESERVED : Used for bpch file output
!=================================================================
INTEGER :: IOFF, JOFF, LOFF
INTEGER :: I0, J0
INTEGER :: ND49_N_TRACERS, ND49_TRACERS(120)
INTEGER :: ND49_IMIN, ND49_IMAX
INTEGER :: ND49_JMIN, ND49_JMAX
INTEGER :: ND49_LMIN, ND49_LMAX
INTEGER :: ND49_FREQ, ND49_NI
INTEGER :: ND49_NJ, ND49_NL
INTEGER :: HALFPOLAR
INTEGER, PARAMETER :: CENTER180=1
REAL*4 :: LONRES, LATRES
CHARACTER(LEN=20) :: MODELNAME
CHARACTER(LEN=40) :: RESERVED = ''
CHARACTER(LEN=80) :: TITLE
CHARACTER(LEN=255) :: ND49_OUTPUT_FILE
CONTAINS
!EOC
!------------------------------------------------------------------------------
! Harvard University Atmospheric Chemistry Modeling Group !
!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE: diag49
!
! !DESCRIPTION: Subroutine DIAG49 produces time series (instantaneous fields)
! for a geographical domain from the information read in timeseries.dat.
! Output will be in binary punch (BPCH) format.
!\\
!\\
! !INTERFACE:
!
SUBROUTINE DIAG49
!
! !USES:
!
USE BPCH2_MOD, ONLY : BPCH2, OPEN_BPCH2_FOR_WRITE
USE FILE_MOD, ONLY : IU_ND49
USE GRID_MOD, ONLY : GET_XOFFSET, GET_YOFFSET
USE TIME_MOD, ONLY : EXPAND_DATE
USE TIME_MOD, ONLY : GET_NYMD, GET_NHMS
USE TIME_MOD, ONLY : GET_NYMD_DIAG, GET_TS_DIAG
USE TIME_MOD, ONLY : GET_TAU, GET_HOUR
USE TIME_MOD, ONLY : ITS_A_NEW_DAY, TIMESTAMP_STRING
! USE LOGICAL_MOD, ONLY : LSOILNOX, LFERTILIZERNOX
USE LOGICAL_MOD, ONLY : LSOILNH3, LFERTILIZERNH3
# include "CMN_SIZE" ! Size parameters
# include "commsoil.h" ! SOILNH3
!# include "commsoil.h" ! SOILNOX
!
! !REVISION HISTORY:
! 09 Apr 1999 - I. Bey, R. Martin, R. Yantosca - Initial version
! (1 ) Now bundled into "diag49_mod.f". Now reference STT from
! "tracer_mod.f". Now scale aerosol & dust OD's to 400 nm.
! (bmy, rvm, aad, 7/9/04)
! (2 ) Updated tracer # for NO2 (bmy, 10/25/04)
! (3 ) Remove reference to "CMN". Also now get PBL heights in meters and
! model layers from GET_PBL_TOP_m and GET_PBL_TOP_L of "pbl_mix_mod.f".
! (bmy, 2/16/05)
! (4 ) Now reference CLDF and BXHEIGHT from "dao_mod.f". Now save 3-D cloud
! fraction as tracer #79 and box height as tracer #93. Now remove
! reference to PBL from "dao_mod.f"(bmy, 4/20/05)
! (5 ) Remove references to TRCOFFSET because it is always zero (bmy, 6/24/05)
! (6 ) Now do not save SLP data if it is not allocated (bmy, 8/2/05)
! (7 ) Now make sure all USE statements are USE, ONLY (bmy, 10/3/05)
! (8 ) Now references XNUMOLAIR from "tracer_mod.f". Bug fix: now must sum
! aerosol OD's over all RH bins. Also zero Q array. (bmy, 11/1/05)
! (9 ) Bug fix: accumulate into Q(X,Y,K) for dust OD (qli, bmy, 4/30/07)
! (10) Bug fix: UNIT should be "levels" for tracer 77. Also RH should be
! tracer #17 under "TIME-SER" category. (cdh, bmy, 2/11/08)
! (11) Bug fix: replace "PS-PTOP" with "PEDGE-$" (bmy, phs, 10/7/08)
! (12) Change the new day condition to open a new file. (ccc, 8/12/09)
! (13) Change the timestamp for the filename when closing (ccc, 8/12/09)
! (14) Add outputs for EMISS_BVOC (10 tracers), TS, PARDR, PARDF and ISOLAI
! (mpb, 11/19/09)
! 02 Dec 2010 - R. Yantosca - Added ProTeX headers
!EOP
!------------------------------------------------------------------------------
!BOC
!
! !LOCAL VARIABLES:
!
LOGICAL, SAVE :: FIRST = .TRUE.
! LOGICAL, SAVE :: IS_FULLCHEM, IS_NOx, IS_Ox
LOGICAL, SAVE :: IS_FULLCHEM, IS_NH3, IS_Ox
LOGICAL, SAVE :: IS_NOy, IS_CLDTOPS, IS_OPTD
LOGICAL, SAVE :: IS_SEASALT, IS_SLP
INTEGER :: IOS, GMTRC, GMNL, I, J, K, L
INTEGER :: N, R, H, W, X, Y
INTEGER :: NHMS, TS_DIAG
REAL*8 :: TAU, TMP, SCALEAODnm
REAL*8 :: Q( ND49_NI, ND49_NJ, ND49_NL )
CHARACTER(LEN=16) :: STAMP
CHARACTER(LEN=40) :: CATEGORY
CHARACTER(LEN=40) :: UNIT
CHARACTER(LEN=255) :: FILENAME
! Aerosol types (rvm, aad, bmy, 7/20/04)
INTEGER :: IND(6) = (/ 22, 29, 36, 43, 50, 15 /)
!=================================================================
! DIAG49 begins here!
!=================================================================
! Set logical flags on first timestep
IF ( FIRST ) THEN
FIRST = .FALSE.
ENDIF
!=================================================================
! If it's a new day, open a new BPCH file and write file header
! We need to check if it's a new day + 1 ND49 time step (ccc, 8/12/09)
!=================================================================
!--- Previous to (ccc, 8/12/09)
! IF ( ITS_A_NEW_DAY() ) THEN
NHMS = GET_NHMS()
TS_DIAG = ND49_FREQ
! To change TS_DIAG to NHMS format
TS_DIAG = TS_DIAG/60 * 10000 + (TS_DIAG - (TS_DIAG/60)*60) * 100
IF ( NHMS == TS_DIAG ) THEN ! It's a new day for diagnostics.
! Expand date tokens in the file name
FILENAME = TRIM( ND49_OUTPUT_FILE )
CALL EXPAND_DATE( FILENAME, GET_NYMD(), GET_NHMS() )
! Echo info
WRITE( 6, 100 ) TRIM( FILENAME )
100 FORMAT( ' - DIAG49: Opening file ', a )
! Open bpch file and write top-of-file header
CALL OPEN_BPCH2_FOR_WRITE( IU_ND49, FILENAME, TITLE )
ENDIF
!=================================================================
! Save tracers to timeseries file
!=================================================================
! Echo info
STAMP = TIMESTAMP_STRING()
WRITE( 6, 110 ) STAMP
110 FORMAT( ' - DIAG49: Saving timeseries at ', a )
! Time for BPCH file
TAU = GET_TAU()
! Zero summing array
Q = 0d0
! Test by tracer number
! modified by chenchuchu 2013/5/24
! IF ( LSOILNOX .and. LFERTILIZERNOX ) THEN
!-------------------------------------
! SOILNOX [molec NOx/cm2/s]
!-------------------------------------
! CATEGORY = 'NOX-SOIL'
! UNIT = 'molec/cm2/s'
! GMNL = 1
! GMTRC = 1
WRITE(6,*) LSOILNH3, LFERTILIZERNH3
IF ( LSOILNH3 .and. LFERTILIZERNH3 ) THEN
!-------------------------------------
! SOILNH3 [molec NH3/cm2/s]
!-------------------------------------
CATEGORY = 'NH3-SOIL'
UNIT = 'molec/cm2/s'
GMNL = 1
GMTRC = 1
!$OMP PARALLEL DO
!$OMP+DEFAULT( SHARED )
!$OMP+PRIVATE( I, J, L, X, Y, K )
DO K = 1, ND49_NL
L = LOFF + K
DO Y = 1, ND49_NJ
J = JOFF + Y
DO X = 1, ND49_NI
I = GET_I( X )
!###Hong Start
Q(X,Y,K) = INST_SOIL(I,J) + INST_FERT(I,J)
!###Hong End
ENDDO
ENDDO
ENDDO
!$OMP END PARALLEL DO
!==============================================================
! Save this data block to the ND49 timeseries file
!==============================================================
CALL BPCH2( IU_ND49, MODELNAME, LONRES,
& LATRES, HALFPOLAR, CENTER180,
& CATEGORY, GMTRC, UNIT,
& TAU, TAU, RESERVED,
& ND49_NI, ND49_NJ, GMNL,
& ND49_IMIN+I0, ND49_JMIN+J0, ND49_LMIN,
& REAL( Q(1:ND49_NI, 1:ND49_NJ, 1:GMNL) ) )
ENDIF
!=================================================================
! Close the file at the proper time
!=================================================================
IF ( ITS_TIME_TO_CLOSE_FILE() ) THEN
! Expand date tokens in the file name
FILENAME = TRIM( ND49_OUTPUT_FILE )
!--- Previous to (ccc, 8/12/09)
! CALL EXPAND_DATE( FILENAME, GET_NYMD(), GET_NHMS() )
CALL EXPAND_DATE( FILENAME, GET_NYMD_DIAG(), GET_NHMS() )
! Echo info
WRITE( 6, 120 ) TRIM( FILENAME )
120 FORMAT( ' - DIAG49: Closing file : ', a )
! Close file
CLOSE( IU_ND49 )
ENDIF
END SUBROUTINE DIAG49
!EOC
!------------------------------------------------------------------------------
! Harvard University Atmospheric Chemistry Modeling Group !
!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE: its_time_to_close_file
!
! !DESCRIPTION: Function ITS\_TIME\_TO\_CLOSE\_FILE returns TRUE if it's
! time to close the ND49 bpch file before the end of the day.
!\\
!\\
! !INTERFACE:
!
FUNCTION ITS_TIME_TO_CLOSE_FILE() RESULT( ITS_TIME )
!
! !USES:
!
USE TIME_MOD, ONLY : GET_HOUR
USE TIME_MOD, ONLY : GET_MINUTE
!
! !RETURN VALUE:
!
LOGICAL :: ITS_TIME
!
! !REVISION HISTORY:
! 20 Jul 2004 - R. Yantosca - Initial version
! (1 ) The time is already updated to the next time step (ccc, 8/12/09)
! 02 Dec 2010 - R. Yantosca - Added ProTeX headers
!EOP
!------------------------------------------------------------------------------
!BOC
!
! !LOCAL VARIABLES:
!
REAL*8 :: HR1
!=================================================================
! ITS_TIME_TO_CLOSE_FILE begins here!
!=================================================================
! Current hour
HR1 = GET_HOUR() + ( GET_MINUTE() / 60d0 )
!--- Previous to (ccc, 8/12/09)
! ! Hour at the next dynamic timestep
! HR2 = HR1 + ( ND49_FREQ / 60d0 )
! If the next dyn step is the start of a new day, return TRUE
!--- Previous to (ccc, 11/11/10)
! HR1 varies between 00 and 23:59. So compares to 00 not 24 anymore.
! ITS_TIME = ( INT( HR1 ) == 24 )
ITS_TIME = ( INT( HR1 ) == 00 )
END FUNCTION ITS_TIME_TO_CLOSE_FILE
!EOC
!------------------------------------------------------------------------------
! Harvard University Atmospheric Chemistry Modeling Group !
!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE: its_time_for_diag49
!
! !DESCRIPTION: Function ITS\_TIME\_FOR\_DIAG49 returns TRUE if ND49 is
! turned on and it is time to call DIAG49 -- or FALSE otherwise.
!\\
!\\
! !INTERFACE:
!
FUNCTION ITS_TIME_FOR_DIAG49() RESULT( ITS_TIME )
!
! !USES:
!
USE TIME_MOD, ONLY : GET_ELAPSED_MIN
USE TIME_MOD, ONLY : GET_TS_DIAG
USE ERROR_MOD, ONLY : GEOS_CHEM_STOP
!
! !RETURN VALUE:
!
LOGICAL :: ITS_TIME
!
! !REVISION HISTORY:
! 20 Jul 2004 - R. Yantosca - Initial version
! (1 ) Add a check on the output frequency for validity compared to time
! steps used. (ccc, 5/21/09)
! 02 Dec 2010 - R. Yantosca - Added ProTeX headers
!EOP
!------------------------------------------------------------------------------
!BOC
!
! !LOCAL VARIABLES:
!
INTEGER :: XMIN, TS_DIAG
LOGICAL, SAVE :: FIRST = .TRUE.
!=================================================================
! ITS_TIME_FOR_DIAG49 begins here!
!=================================================================
IF ( DO_SAVE_DIAG49 ) THEN
IF ( FIRST ) THEN
TS_DIAG = GET_TS_DIAG()
! Check if ND49_FREQ is a multiple of TS_DIAG
IF ( MOD( ND49_FREQ, TS_DIAG ) /= 0 ) THEN
WRITE( 6, 100 ) 'ND49', ND49_FREQ, TS_DIAG
100 FORMAT( 'The ',a,' output frequency must be a multiple '
& 'of the largest time step:', i5, i5 )
CALL GEOS_CHEM_STOP
ENDIF
FIRST = .FALSE.
ENDIF
! Time already elapsed in this run
XMIN = GET_ELAPSED_MIN()
! Is the elapsed time a multiple of ND49_FREQ?
ITS_TIME = ( DO_SAVE_DIAG49 .and. MOD( XMIN, ND49_FREQ ) == 0 )
ELSE
ITS_TIME = DO_SAVE_DIAG49
ENDIF
END FUNCTION ITS_TIME_FOR_DIAG49
!EOC
!------------------------------------------------------------------------------
! Harvard University Atmospheric Chemistry Modeling Group !
!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE: get_i
!
! !DESCRIPTION: Function GET\_I returns the absolute longitude index (I),
! given the relative longitude index (X).
!\\
!\\
! !INTERFACE:
!
FUNCTION GET_I( X ) RESULT( I )
!
! !USES:
!
# include "CMN_SIZE" ! Size parameters
!
! !INPUT PARAMETERS:
!
INTEGER, INTENT(IN) :: X ! Relative longitude index (used by Q array)
!
! !RETURN VALUE:
!
INTEGER :: I ! Absolute longitude index
!
! !REVISION HISTORY:
! 20 Jul 2004 - R. Yantosca - Initial version
! 02 Dec 2010 - R. Yantosca - Added ProTeX headers
!EOP
!------------------------------------------------------------------------------
!BOC
!=================================================================
! GET_I begins here!
!=================================================================
! Add the offset to X to get I
I = IOFF + X
! Handle wrapping around the date line, if necessary
IF ( I > IIPAR ) I = I - IIPAR
END FUNCTION GET_I
!EOC
!------------------------------------------------------------------------------
! Harvard University Atmospheric Chemistry Modeling Group !
!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE: init_diag49
!
! !DESCRIPTION: Subroutine INIT\_DIAG49 allocates and zeroes all module
! arrays. It also gets values for module variables from "input\_mod.f".
!\\
!\\
! !INTERFACE:
!
SUBROUTINE INIT_DIAG49( DO_ND49, N_ND49, TRACERS, IMIN,
& IMAX, JMIN, JMAX, LMIN,
& LMAX, FREQ, FILE )
!
! !USES:
!
USE BPCH2_MOD, ONLY : GET_MODELNAME
USE BPCH2_MOD, ONLY : GET_HALFPOLAR
USE GRID_MOD, ONLY : GET_XOFFSET
USE GRID_MOD, ONLY : GET_YOFFSET
USE GRID_MOD, ONLY : ITS_A_NESTED_GRID
USE ERROR_MOD, ONLY : ERROR_STOP
# include "CMN_SIZE" ! Size parameters
!
! !INPUT PARAMETERS:
!
! DO_ND49 : Switch to turn on ND49 timeseries diagnostic
! N_ND50 : Number of ND49 read by "input_mod.f"
! TRACERS : Array w/ ND49 tracer #'s read by "input_mod.f"
! IMIN : Min longitude index read by "input_mod.f"
! IMAX : Max longitude index read by "input_mod.f"
! JMIN : Min latitude index read by "input_mod.f"
! JMAX : Min latitude index read by "input_mod.f"
! LMIN : Min level index read by "input_mod.f"
! LMAX : Min level index read by "input_mod.f"
! FREQ : Frequency for saving to disk [min]
! FILE : ND49 output file name read by "input_mod.f"
LOGICAL, INTENT(IN) :: DO_ND49
INTEGER, INTENT(IN) :: N_ND49, TRACERS(100)
INTEGER, INTENT(IN) :: IMIN, IMAX
INTEGER, INTENT(IN) :: JMIN, JMAX
INTEGER, INTENT(IN) :: LMIN, LMAX
INTEGER, INTENT(IN) :: FREQ
CHARACTER(LEN=255), INTENT(IN) :: FILE
!
! !REVISION HISTORY:
! 20 Jul 2004 - R. Yantosca - Initial version
! (1 ) Now get I0 and J0 correctly for nested grid simulations (bmy, 11/9/04)
! (2 ) Now call GET_HALFPOLAR from "bpch2_mod.f" to get the HALFPOLAR flag
! value for GEOS or GCAP grids. (bmy, 6/28/05)
! (3 ) Now allow ND49_IMIN to be equal to ND49_IMAX and ND49_JMIN to be
! equal to ND49_JMAX. This will allow us to save out longitude
! or latitude transects. (cdh, bmy, 11/30/06)
! 02 Dec 2010 - R. Yantosca - Added ProTeX headers
!EOP
!------------------------------------------------------------------------------
!BOC
!
! !LOCAL VARIABLES:
!
CHARACTER(LEN=255) :: LOCATION
!=================================================================
! INIT_DIAG49 begins here!
!=================================================================
! Initialize
LOCATION = 'INIT_DIAG49 ("diag49_mod.f")'
ND49_TRACERS(:) = 0
! Get values from "input_mod.f"
DO_SAVE_DIAG49 = DO_ND49
ND49_N_TRACERS = N_ND49
ND49_TRACERS(1:N_ND49) = TRACERS(1:N_ND49)
ND49_IMIN = IMIN
ND49_IMAX = IMAX
ND49_JMIN = JMIN
ND49_JMAX = JMAX
ND49_LMIN = LMIN
ND49_LMAX = LMAX
ND49_FREQ = FREQ
ND49_OUTPUT_FILE = FILE
! Return if we are not saving ND49 diagnostics
IF ( .not. DO_SAVE_DIAG49 ) RETURN
!=================================================================
! Compute lon, lat, alt extents and check for errors
!=================================================================
! Get grid offsets for error checking
IF ( ITS_A_NESTED_GRID() ) THEN
I0 = GET_XOFFSET()
J0 = GET_YOFFSET()
ELSE
I0 = GET_XOFFSET( GLOBAL=.TRUE. )
J0 = GET_YOFFSET( GLOBAL=.TRUE. )
ENDIF
!-----------
! Longitude
!-----------
! Error check ND49_IMIN
IF ( ND49_IMIN+I0 < 1 .or. ND49_IMIN+I0 > IGLOB ) THEN
CALL ERROR_STOP( 'Bad ND49_IMIN value!', LOCATION )
ENDIF
! Error check ND49_IMAX
IF ( ND49_IMAX+I0 < 1 .or. ND49_IMAX+I0 > IGLOB ) THEN
CALL ERROR_STOP( 'Bad ND49_IMAX value!', LOCATION )
ENDIF
! Compute longitude limits to write to disk
! Also handle wrapping around the date line
IF ( ND49_IMAX >= ND49_IMIN ) THEN
ND49_NI = ( ND49_IMAX - ND49_IMIN ) + 1
ELSE
ND49_NI = ( IIPAR - ND49_IMIN ) + 1 + ND49_IMAX
WRITE( 6, '(a)' ) 'We are wrapping over the date line!'
ENDIF
! Make sure that ND49_NI <= IIPAR
IF ( ND49_NI > IIPAR ) THEN
CALL ERROR_STOP( 'Too many longitudes!', LOCATION )
ENDIF
!-----------
! Latitude
!-----------
! Error check JMIN_AREA
IF ( ND49_JMIN+J0 < 1 .or. ND49_JMIN+J0 > JGLOB ) THEN
CALL ERROR_STOP( 'Bad ND49_JMIN value!', LOCATION)
ENDIF
! Error check JMAX_AREA
IF ( ND49_JMAX+J0 < 1 .or.ND49_JMAX+J0 > JGLOB ) THEN
CALL ERROR_STOP( 'Bad ND49_JMAX value!', LOCATION)
ENDIF
! Compute latitude limits to write to disk (bey, bmy, 3/16/99)
IF ( ND49_JMAX >= ND49_JMIN ) THEN
ND49_NJ = ( ND49_JMAX - ND49_JMIN ) + 1
ELSE
CALL ERROR_STOP( 'ND49_JMAX < ND49_JMIN!', LOCATION )
ENDIF
!-----------
! Altitude
!-----------
! Error check ND49_LMIN, ND49_LMAX
IF ( ND49_LMIN < 1 .or. ND49_LMAX > LLPAR ) THEN
CALL ERROR_STOP( 'Bad ND49 altitude values!', LOCATION )
ENDIF
! # of levels to save in ND49 timeseries
IF ( ND49_LMAX >= ND49_LMIN ) THEN
ND49_NL = ( ND49_LMAX - ND49_LMIN ) + 1
ELSE
CALL ERROR_STOP( 'ND49_LMAX < ND49_LMIN!', LOCATION )
ENDIF
!-----------
! Offsets
!-----------
IOFF = ND49_IMIN - 1
JOFF = ND49_JMIN - 1
LOFF = ND49_LMIN - 1
!-----------
! For bpch
!-----------
TITLE = 'GEOS-CHEM DIAG49 instantaneous timeseries'
LONRES = DISIZE
LATRES = DJSIZE
MODELNAME = GET_MODELNAME()
HALFPOLAR = GET_HALFPOLAR()
! Reset grid offsets to global values for bpch write
I0 = GET_XOFFSET( GLOBAL=.TRUE. )
J0 = GET_YOFFSET( GLOBAL=.TRUE. )
END SUBROUTINE INIT_DIAG49
!EOC
END MODULE DIAG49_MOD
|
SUBROUTINE QGRDFI (U, ROW, M, LROW, TYPE)
C-----------------------------------------------------------------------
C! FPS AP version: Finished gridding row of UV data
C# AP-util
C-----------------------------------------------------------------------
C; Copyright (C) 1995
C; Associated Universities, Inc. Washington DC, USA.
C;
C; This program is free software; you can redistribute it and/or
C; modify it under the terms of the GNU General Public License as
C; published by the Free Software Foundation; either version 2 of
C; the License, or (at your option) any later version.
C;
C; This program is distributed in the hope that it will be useful,
C; but WITHOUT ANY WARRANTY; without even the implied warranty of
C; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
C; GNU General Public License for more details.
C;
C; You should have received a copy of the GNU General Public
C; License along with this program; if not, write to the Free
C; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
C; MA 02139, USA.
C;
C; Correspondence concerning AIPS should be addressed as follows:
C; Internet email: aipsmail@nrao.edu.
C; Postal address: AIPS Project Office
C; National Radio Astronomy Observatory
C; 520 Edgemont Road
C; Charlottesville, VA 22903-2475 USA
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C FPS AP version
C Does various tasks assiciated with completion of gridding
C a row. If U is within 1/2 support of 0 the symmetric row is
C conjugated, flipped and added. Next
C any taper is applied followed (for IPOL maps only) by the
C addition of the weighting function to the gridded visibilities
C to produce the beam map. Finally rows are rotated so that
C zero column (assumed LROW/2+1) goes to the first column.
C If U=0 the space for the next row down is used.
C Inputs:
C U I U in cells (non-negative)
C ROW I Base address of Grid row of interest
C M I Number of rows kept in the AP.
C LROW I Length of row (no. reals)
C TYPE I 1 for IPOL,IBEM maps
C 2 for Q, U maps
C 3 for V maps.
C Also expects necessary constants in following AP locations:
C 0 = COS(PHASE0) to shift map center
C 1 = SIN(PHASE0)
C 2 = COS(DELPHR) for rotating down rows
C 3 = SIN(DELPHR)
C 4 = COS(DELPHC) for rotationg down columns
C 5 = SIN(DELPHC)
C 6 = 1.0
C 7 = 0.0
C-----------------------------------------------------------------------
INTEGER U, ROW, M, LROW, TYPE
INTEGER*2 IU, IROW, IM, ILROW, ITYPE
C-----------------------------------------------------------------------
C Convert inputs to unsigned I*2
IF (U.LT.32768) IU = U
IF (U.GE.32768) IU = U - 65536
IF (ROW.LT.32768) IROW = ROW
IF (ROW.GE.32768) IROW = ROW - 65536
IF (M.LT.32768) IM = M
IF (M.GE.32768) IM = M - 65536
IF (LROW.LT.32768) ILROW = LROW
IF (LROW.GE.32768) ILROW = LROW - 65536
ITYPE = TYPE
C Call FPS routine.
CALL GRDFIN (IU, IROW, IM, ILROW, ITYPE)
C
999 RETURN
END
|
subroutine dft_spinflip(g_dens,g_s,basis,c_a,c_b,
S no_sflip,at_flip)
C$Id$
implicit none
#include "errquit.fh"
#include "mafdecls.fh"
#include "global.fh"
#include "bas.fh"
#include "geom.fh"
integer g_dens(2)
integer g_s
integer basis,geom
double precision c_a,c_b
integer no_sflip
integer at_flip(no_sflip)
c
integer at,ii,nbf
integer ilo,ihi,ld
integer l_dm,k_dm
double precision pstrace_in,pstrace_out
c
c g_dens(2) has -B
c compute spin DM and store it in g_dens(2)
c
! call ga_add(1d0, g_dens(1), -1d0, g_dens(2), g_dens(2))
clast call ga_add(1d0, g_dens(1), -2d0, g_dens(2), g_dens(2))
call ga_add(c_a, g_dens(1), c_b, g_dens(2), g_dens(2))
c
c check on trace(spin_dm *S)
c
pstrace_in=ga_ddot(g_dens(2),g_s)
if(ga_nodeid().eq.0) then
write(6,*) ' spinflip: input pstrace ',pstrace_in
if (.not. bas_numbf(basis, nbf)) call errquit
$ ('dft_spinflip: bas_numbf ?', 0, BASIS_ERR)
do ii=1,no_sflip
at=at_flip(ii)
write(6,*) ' spinflip: flipping at ',at
c
c grab atomic block and invert sign
c
if (.not. bas_ce2bfr(basis, at, ilo, ihi)) call errquit
$ ('dft_spinflip: bas_ce2bfr ?', 0, BASIS_ERR)
ld=ihi-ilo+1
if (ld .gt. 0) then
if (.not.MA_Push_Get(MT_Dbl,ld*ld,'dm',
F l_dm,k_dm))
& call errquit('dft_spinf: cannot allocate',0, MA_ERR)
call ga_get(g_dens(2),ilo,ihi,ilo,ihi,dbl_mb(k_dm),ld)
call dscal(ld*ld,-1d0,dbl_mb(k_dm),1)
call ga_put(g_dens(2),ilo,ihi,ilo,ihi,dbl_mb(k_dm),ld)
if (.not.ma_pop_stack(l_dm))
& call errquit('dft_spinf: cannot pop stack',3,MA_ERR)
else
call errquit('dftspinflip: no basis for atom ',
B at,BASIS_ERR)
endif
enddo
endif
call ga_sync()
pstrace_out=ga_ddot(g_dens(2),g_s)
if(ga_nodeid().eq.0) then
write(6,*) ' spinflip: output pstrace ',pstrace_out
if(abs(pstrace_in-pstrace_out).gt.1d-3) write(6,*)
W 'WARNING: large change in pstrace!'
endif
c restore - beta in g_dens(2)
c A - (A -B) = B
! call ga_add(1d0, g_dens(1), -1d0, g_dens(2), g_dens(2))
clast call ga_add(0.5d0, g_dens(1), -0.5d0, g_dens(2), g_dens(2))
call ga_add(-c_a/c_b, g_dens(1), 1d0/c_b, g_dens(2), g_dens(2))
return
end
|
subroutine get_dampfac(io,nl,dmscale,dmnorm,dmgrad)
dimension dmscale(1),dmnorm(1),dmgrad(1)
c
c read a damping factor file to get the factors for block diagonal damping
c for each sub-layer of the model, for example, 14 basis function means
c 14 sublayers (or radial splines) for the inversion.
c Input: io ---- file number
c nl ---- number of expected layers
c Output:
c dmwate ---- scaling factor for damping matrix
c dmnorm ---- norm damping factor
c dmgrad ---- gradient damping factor
c
character*256 dampfile
write(*, "('enter the file that contains the damping factors')")
write(*, "('contents of the file:')")
write(*, "('-----------------------------------------------------------------------------------')")
write(*, "('first line[mandatory, 4 entries]: #_of_layers multiplier %norm %gradient ')")
write(*, "('other lines [optional,4 entries]: spec_layer# %_of_multplier %norm %gradient ')")
write(*, "('-----------------------------------------------------------------------------------')")
read(*,"(a)") dampfile
open(io, file=dampfile, iostat=ios)
if(ios.ne.0) then
stop 'problem with this file!'
endif
do i=1, nl
dmscale(i)=0.0
dmnorm(i)=0.0
dmgrad(i)=0.0
enddo
read(io,*) nlayer, scale,facnorm,facgrad
if(nlayer.ne.nl) stop 'number of expected radial parm not consistent!'
do i=1, nl
dmscale(i)=scale
dmnorm(i)=facnorm
dmgrad(i)=facgrad
enddo
10 read(io, *, end=20) ilayer,sc,facnorm,facgrad
dmscale(ilayer)=dmscale(ilayer)*sc
dmnorm(ilayer)=facnorm
dmgrad(ilayer)=facgrad
goto 10
20 continue
close(io)
write(*,*)
print*, 'SCALING AND DAMPING FACTORS:'
print*, '-----------------------------------------------------'
print*, 'layer# scaling_fac norm_damp grad_damp'
print*, '-----------------------------------------------------'
do idmp=1, nl
print*, idmp, dmscale(idmp), dmnorm(idmp), dmgrad(idmp)
enddo
return
end
|
C$Procedure GFRFOV ( GF, is ray in FOV? )
SUBROUTINE GFRFOV ( INST, RAYDIR, RFRAME, ABCORR,
. OBSRVR, STEP, CNFINE, RESULT )
C$ Abstract
C
C Determine time intervals when a specified ray intersects the
C space bounded by the field-of-view (FOV) of a specified
C instrument.
C
C$ Disclaimer
C
C THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
C CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
C GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
C ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
C PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
C TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
C WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
C PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
C SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
C SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
C
C IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
C BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
C LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
C INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
C REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
C REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
C
C RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
C THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
C CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
C ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
C
C$ Required_Reading
C
C CK
C FRAMES
C GF
C KERNEL
C NAIF_IDS
C PCK
C SPK
C TIME
C WINDOWS
C
C$ Keywords
C
C EVENT
C FOV
C GEOMETRY
C INSTRUMENT
C SEARCH
C WINDOW
C
C$ Declarations
IMPLICIT NONE
INCLUDE 'gf.inc'
INCLUDE 'zzholdd.inc'
INTEGER LBCELL
PARAMETER ( LBCELL = -5 )
CHARACTER*(*) INST
DOUBLE PRECISION RAYDIR ( 3 )
CHARACTER*(*) RFRAME
CHARACTER*(*) ABCORR
CHARACTER*(*) OBSRVR
DOUBLE PRECISION STEP
DOUBLE PRECISION CNFINE ( LBCELL : * )
DOUBLE PRECISION RESULT ( LBCELL : * )
C$ Brief_I/O
C
C VARIABLE I/O DESCRIPTION
C -------- --- --------------------------------------------------
C MARGIN P Minimum complement of FOV cone angle.
C LBCELL P SPICE Cell lower bound.
C CNVTOL P Convergence tolerance.
C MAXVRT P Maximum number of FOV boundary vertices.
C ZZGET P ZZHOLDD retrieves a stored DP value.
C GF_TOL P ZZHOLDD acts on the GF subsystem tolerance.
C INST I Name of the instrument.
C RAYDIR I Ray's direction vector.
C RFRAME I Reference frame of ray's direction vector.
C ABCORR I Aberration correction flag.
C OBSRVR I Name of the observing body.
C STEP I Step size in seconds for finding FOV events.
C CNFINE I SPICE window to which the search is restricted.
C RESULT O SPICE window containing results.
C
C
C$ Detailed_Input
C
C
C INST indicates the name of an instrument, such as a
C spacecraft-mounted framing camera, the field of view
C (FOV) of which is to be used for an target intersection
C search: the direction from the observer to a target
C is represented by a ray, and times when the specified
C ray intersects the region of space bounded by the FOV
C are sought.
C
C The position of the instrument designated by INST is
C considered to coincide with that of the ephemeris
C object designated by the input argument OBSRVR (see
C description below).
C
C INST must have a corresponding NAIF ID and a frame
C defined, as is normally done in a frame kernel. It
C must also have an associated reference frame and a FOV
C shape, boresight and boundary vertices (or reference
C vector and reference angles) defined, as is usually
C done in an instrument kernel.
C
C See the header of the SPICELIB routine GETFOV for a
C description of the required parameters associated with
C an instrument.
C
C
C RAYDIR is the direction vector associated with a ray
C representing a target. The ray emanates from the
C location of the ephemeris object designated by the
C input argument OBSRVR and is expressed relative to the
C reference frame designated by RFRAME (see descriptions
C below).
C
C
C RFRAME is the name of the reference frame associated with
C the input ray's direction vector RAYDIR.
C
C Since light time corrections are not supported for
C rays, the orientation of the frame is always evaluated
C at the epoch associated with the observer, as opposed
C to the epoch associated with the light-time corrected
C position of the frame center.
C
C Case and leading or trailing blanks bracketing a
C non-blank frame name are not significant in the string
C RFRAME.
C
C
C ABCORR indicates the aberration corrections to be applied
C when computing the ray's direction.
C
C The supported aberration correction options are
C
C 'NONE' No correction.
C 'S' Stellar aberration correction,
C reception case.
C 'XS' Stellar aberration correction,
C transmission case.
C
C For detailed information, see the geometry finder
C required reading, gf.req.
C
C Case, leading and trailing blanks are not significant
C in the string ABCORR.
C
C
C OBSRVR is the name of the body from which the target
C represented by RAYDIR is observed. The instrument
C designated by INST is treated as if it were co-located
C with the observer.
C Optionally, you may supply the integer NAIF ID code
C for the body as a string.
C
C Case and leading or trailing blanks are not
C significant in the string OBSRVR.
C
C
C STEP is the step size to be used in the search. STEP must
C be shorter than any interval, within the confinement
C window, over which the specified condition is met. In
C other words, STEP must be shorter than the shortest
C visibility event that the user wishes to detect. STEP
C also must be shorter than the minimum duration
C separating any two visibility events. However, STEP
C must not be *too* short, or the search will take an
C unreasonable amount of time.
C
C The choice of STEP affects the completeness but not
C the precision of solutions found by this routine; the
C precision is controlled by the convergence tolerance.
C See the discussion of the parameter CNVTOL for
C details.
C
C STEP has units of seconds.
C
C
C CNFINE is a SPICE window that confines the time period over
C which the specified search is conducted. CNFINE may
C consist of a single interval or a collection of
C intervals.
C
C The endpoints of the time intervals comprising CNFINE
C are interpreted as seconds past J2000 TDB.
C
C See the Examples section below for a code example
C that shows how to create a confinement window.
C
C CNFINE must be initialized by the caller via the
C SPICELIB routine SSIZED.
C
C$ Detailed_Output
C
C
C RESULT is a SPICE window representing the set of time
C intervals, within the confinement period, when the
C input ray is "visible"; that is, when the ray is
C contained in the space bounded by the specified
C instrument's field of view.
C
C The endpoints of the time intervals comprising RESULT
C are interpreted as seconds past J2000 TDB.
C
C If RESULT is non-empty on input, its contents
C will be discarded before GFRFOV conducts its
C search.
C
C$ Parameters
C
C LBCELL is the lower bound for SPICE cell arrays.
C
C CNVTOL is the convergence tolerance used for finding
C endpoints of the intervals comprising the result
C window. CNVTOL is used to determine when binary
C searches for roots should terminate: when a root is
C bracketed within an interval of length CNVTOL; the
C root is considered to have been found.
C
C The accuracy, as opposed to precision, of roots found
C by this routine depends on the accuracy of the input
C data. In most cases, the accuracy of solutions will be
C inferior to their precision.
C
C MAXVRT is the maximum number of vertices that may be used
C to define the boundary of the specified instrument's
C field of view.
C
C MARGIN is a small positive number used to constrain the
C orientation of the boundary vectors of polygonal
C FOVs. Such FOVs must satisfy the following constraints:
C
C 1) The boundary vectors must be contained within
C a right circular cone of angular radius less
C than than (pi/2) - MARGIN radians; in other
C words, there must be a vector A such that all
C boundary vectors have angular separation from
C A of less than (pi/2)-MARGIN radians.
C
C 2) There must be a pair of boundary vectors U, V
C such that all other boundary vectors lie in
C the same half space bounded by the plane
C containing U and V. Furthermore, all other
C boundary vectors must have orthogonal
C projections onto a specific plane normal to
C this plane (the normal plane contains the angle
C bisector defined by U and V) such that the
C projections have angular separation of at least
C 2*MARGIN radians from the plane spanned by U
C and V.
C
C MARGIN is currently set to 1.D-12.
C
C
C See INCLUDE file gf.inc for declarations and descriptions of
C parameters used throughout the GF system.
C
C$ Exceptions
C
C
C 1) In order for this routine to produce correct results,
C the step size must be appropriate for the problem at hand.
C Step sizes that are too large may cause this routine to miss
C roots; step sizes that are too small may cause this routine
C to run unacceptably slowly and in some cases, find spurious
C roots.
C
C This routine does not diagnose invalid step sizes, except
C that if the step size is non-positive, the error
C SPICE(INVALIDSTEPSIZE) will be signaled.
C
C 2) Due to numerical errors, in particular,
C
C - Truncation error in time values
C - Finite tolerance value
C - Errors in computed geometric quantities
C
C it is *normal* for the condition of interest to not always be
C satisfied near the endpoints of the intervals comprising the
C result window.
C
C The result window may need to be contracted slightly by the
C caller to achieve desired results. The SPICE window routine
C WNCOND can be used to contract the result window.
C
C 3) If the observer's name cannot be mapped to an ID code, the
C error SPICE(IDCODENOTFOUND) is signaled.
C
C 4) If the aberration correction flag calls for light time
C correction, the error SPICE(INVALIDOPTION) is signaled.
C
C 5) If the ray's direction vector is zero, the error
C SPICE(ZEROVECTOR) is signaled.
C
C 6) If the instrument name INST does not have corresponding NAIF
C ID code, the error will be diagnosed by a routine in the call
C tree of this routine.
C
C 7) If the FOV parameters of the instrument are not present in
C the kernel pool, the error will be be diagnosed by routines
C in the call tree of this routine.
C
C 8) If the FOV boundary has more than MAXVRT vertices, the error
C will be be diagnosed by routines in the call tree of this
C routine.
C
C 9) If the instrument FOV is polygonal, and this routine cannot
C find a ray R emanating from the FOV vertex such that maximum
C angular separation of R and any FOV boundary vector is within
C the limit (pi/2)-MARGIN radians, the error will be diagnosed
C by a routine in the call tree of this routine. If the FOV
C is any other shape, the same error check will be applied with
C the instrument boresight vector serving the role of R.
C
C 10) If the loaded kernels provide insufficient data to compute a
C requested state vector, the error will be diagnosed by a
C routine in the call tree of this routine.
C
C 11) If an error occurs while reading an SPK or other kernel file,
C the error will be diagnosed by a routine in the call tree
C of this routine.
C
C 12) If the output SPICE window RESULT has insufficient capacity
C to contain the number of intervals on which the specified
C visibility condition is met, the error will be diagnosed
C by a routine in the call tree of this routine. If the result
C window has size less than 2, the error SPICE(WINDOWTOOSMALL)
C will be signaled by this routine.
C
C$ Files
C
C Appropriate SPICE kernels must be loaded by the calling program
C before this routine is called.
C
C The following data are required:
C
C - SPK data: ephemeris data for the observer for the period
C defined by the confinement window 'CNFINE' must be loaded.
C If aberration corrections are used, the state of the
C observer relative to the solar system barycenter must be
C calculable from the available ephemeris data. Typically
C ephemeris data are made available by loading one or more SPK
C files via FURNSH.
C
C - Data defining the reference frame associated with the
C instrument designated by INST must be available in the kernel
C pool. Additionally the name INST must be associated with an
C ID code. Normally these data are made available by loading
C a frame kernel via FURNSH.
C
C - IK data: the kernel pool must contain data such that
C the SPICELIB routine GETFOV may be called to obtain
C parameters for INST. Normally such data are provided by
C an IK via FURNSH.
C
C The following data may be required:
C
C - CK data: if the instrument frame is fixed to a spacecraft,
C at least one CK file will be needed to permit transformation
C of vectors between that frame and the J2000 frame.
C
C - SCLK data: if a CK file is needed, an associated SCLK
C kernel is required to enable conversion between encoded SCLK
C (used to time-tag CK data) and barycentric dynamical time
C (TDB).
C
C - Since the input ray direction may be expressed in any
C frame, FKs, CKs, SCLK kernels, PCKs, and SPKs may be
C required to map the direction to the J2000 frame.
C
C Kernel data are normally loaded once per program run, NOT every
C time this routine is called.
C
C$ Particulars
C
C This routine determines a set of one or more time intervals when
C the specified ray in contained within the field of view of a
C specified instrument. We'll use the term "visibility event" to
C designate such an appearance. The set of time intervals resulting
C from the search is returned as a SPICE window.
C
C This routine provides a simpler, but less flexible, interface
C than does the SPICELIB routine GFFOVE for conducting searches for
C visibility events. Applications that require support for progress
C reporting, interrupt handling, non-default step or refinement
C functions, or non-default convergence tolerance should call
C GFFOVE rather than this routine.
C
C Below we discuss in greater detail aspects of this routine's
C solution process that are relevant to correct and efficient use
C of this routine in user applications.
C
C
C The Search Process
C ==================
C
C The search for visibility events is treated as a search for state
C transitions: times are sought when the state of the ray
C changes from "not visible" to "visible" or vice versa.
C
C Step Size
C =========
C
C Each interval of the confinement window is searched as follows:
C first, the input step size is used to determine the time
C separation at which the visibility state will be sampled.
C Starting at the left endpoint of an interval, samples will be
C taken at each step. If a state change is detected, a root has
C been bracketed; at that point, the "root"--the time at which the
C state change occurs---is found by a refinement process, for
C example, via binary search.
C
C Note that the optimal choice of step size depends on the lengths
C of the intervals over which the visibility state is constant:
C the step size should be shorter than the shortest visibility event
C duration and the shortest period between visibility events, within
C the confinement window.
C
C Having some knowledge of the relative geometry of the ray and
C observer can be a valuable aid in picking a reasonable step size.
C In general, the user can compensate for lack of such knowledge by
C picking a very short step size; the cost is increased computation
C time.
C
C Note that the step size is not related to the precision with which
C the endpoints of the intervals of the result window are computed.
C That precision level is controlled by the convergence tolerance.
C
C
C Convergence Tolerance
C =====================
C
C Once a root has been bracketed, a refinement process is used to
C narrow down the time interval within which the root must lie.
C This refinement process terminates when the location of the root
C has been determined to within an error margin called the
C "convergence tolerance." The default convergence tolerance
C used by this routine is set by the parameter CNVTOL (defined
C in gf.inc).
C
C The value of CNVTOL is set to a "tight" value so that the
C tolerance doesn't become the limiting factor in the accuracy of
C solutions found by this routine. In general the accuracy of input
C data will be the limiting factor.
C
C The user may change the convergence tolerance from the default
C CNVTOL value by calling the routine GFSTOL, e.g.
C
C CALL GFSTOL( tolerance value )
C
C Call GFSTOL prior to calling this routine. All subsequent
C searches will use the updated tolerance value.
C
C Setting the tolerance tighter than CNVTOL is unlikely to be
C useful, since the results are unlikely to be more accurate.
C Making the tolerance looser will speed up searches somewhat,
C since a few convergence steps will be omitted. However, in most
C cases, the step size is likely to have a much greater effect
C on processing time than would the convergence tolerance.
C
C
C The Confinement Window
C ======================
C
C The simplest use of the confinement window is to specify a time
C interval within which a solution is sought. However, the
C confinement window can, in some cases, be used to make searches
C more efficient. Sometimes it's possible to do an efficient search
C to reduce the size of the time period over which a relatively
C slow search of interest must be performed. For an example, see
C the program CASCADE in the GF Example Programs chapter of the GF
C Required Reading, gf.req.
C
C$ Examples
C
C
C The numerical results shown for these examples may differ across
C platforms. The results depend on the SPICE kernels used as
C input, the compiler and supporting libraries, and the machine
C specific arithmetic implementation.
C
C
C 1) This example is an extension of example #1 in the
C header of
C
C GFTFOV
C
C The problem statement for that example is
C
C Search for times when Saturn's satellite Phoebe is within
C the FOV of the Cassini narrow angle camera
C (CASSINI_ISS_NAC). To simplify the problem, restrict the
C search to a short time period where continuous Cassini bus
C attitude data are available.
C
C Use a step size of 10 seconds to reduce chances of missing
C short visibility events.
C
C Here we search the same confinement window for times when a
C selected background star is visible. We use the FOV of the
C Cassini ISS wide angle camera (CASSINI_ISS_WAC) to enhance the
C probability of viewing the star.
C
C The star we'll use has catalog number 6000 in the Hipparcos
C Catalog. The star's J2000 right ascension and declination,
C proper motion, and parallax are taken from that catalog.
C
C Use the meta-kernel from the GFTFOV example:
C
C
C KPL/MK
C
C File name: gftfov_ex1.tm
C
C This meta-kernel is intended to support operation of SPICE
C example programs. The kernels shown here should not be
C assumed to contain adequate or correct versions of data
C required by SPICE-based user applications.
C
C In order for an application to use this meta-kernel, the
C kernels referenced here must be present in the user's
C current working directory.
C
C The names and contents of the kernels referenced
C by this meta-kernel are as follows:
C
C File name Contents
C --------- --------
C naif0009.tls Leapseconds
C cpck05Mar2004.tpc Satellite orientation and
C radii
C 981005_PLTEPH-DE405S.bsp Planetary ephemeris
C 020514_SE_SAT105.bsp Satellite ephemeris
C 030201AP_SK_SM546_T45.bsp Spacecraft ephemeris
C cas_v37.tf Cassini FK
C 04135_04171pc_psiv2.bc Cassini bus CK
C cas00084.tsc Cassini SCLK kernel
C cas_iss_v09.ti Cassini IK
C
C
C \begindata
C
C KERNELS_TO_LOAD = ( 'naif0009.tls',
C 'cpck05Mar2004.tpc',
C '981005_PLTEPH-DE405S.bsp',
C '020514_SE_SAT105.bsp',
C '030201AP_SK_SM546_T45.bsp',
C 'cas_v37.tf',
C '04135_04171pc_psiv2.bc',
C 'cas00084.tsc',
C 'cas_iss_v09.ti' )
C \begintext
C
C
C
C Example code begins here.
C
C
C PROGRAM EX1
C IMPLICIT NONE
C C
C C SPICELIB functions
C C
C DOUBLE PRECISION J1950
C DOUBLE PRECISION J2000
C DOUBLE PRECISION JYEAR
C DOUBLE PRECISION RPD
C
C INTEGER WNCARD
C
C C
C C Local parameters
C C
C CHARACTER*(*) META
C PARAMETER ( META = 'gftfov_ex1.tm' )
C
C CHARACTER*(*) TIMFMT
C PARAMETER ( TIMFMT =
C . 'YYYY-MON-DD HR:MN:SC.######::TDB (TDB)' )
C
C
C DOUBLE PRECISION AU
C PARAMETER ( AU = 149597870.693D0 )
C
C INTEGER LBCELL
C PARAMETER ( LBCELL = -5 )
C
C INTEGER MAXWIN
C PARAMETER ( MAXWIN = 10000 )
C
C INTEGER CORLEN
C PARAMETER ( CORLEN = 10 )
C
C INTEGER BDNMLN
C PARAMETER ( BDNMLN = 36 )
C
C INTEGER FRNMLN
C PARAMETER ( FRNMLN = 32 )
C
C INTEGER TIMLEN
C PARAMETER ( TIMLEN = 35 )
C
C INTEGER LNSIZE
C PARAMETER ( LNSIZE = 80 )
C
C C
C C Local variables
C C
C CHARACTER*(CORLEN) ABCORR
C CHARACTER*(BDNMLN) INST
C CHARACTER*(LNSIZE) LINE
C CHARACTER*(BDNMLN) OBSRVR
C CHARACTER*(FRNMLN) RFRAME
C CHARACTER*(TIMLEN) TIMSTR ( 2 )
C
C DOUBLE PRECISION CNFINE ( LBCELL : MAXWIN )
C DOUBLE PRECISION DEC
C DOUBLE PRECISION DECEPC
C DOUBLE PRECISION DECPM
C DOUBLE PRECISION DECDEG
C DOUBLE PRECISION DECDG0
C DOUBLE PRECISION DTDEC
C DOUBLE PRECISION DTRA
C DOUBLE PRECISION ENDPT ( 2 )
C DOUBLE PRECISION ET0
C DOUBLE PRECISION ET1
C DOUBLE PRECISION LT
C DOUBLE PRECISION PARLAX
C DOUBLE PRECISION PLXDEG
C DOUBLE PRECISION POS ( 3 )
C DOUBLE PRECISION PSTAR ( 3 )
C DOUBLE PRECISION RA
C DOUBLE PRECISION RADEG
C DOUBLE PRECISION RADEG0
C DOUBLE PRECISION RAEPC
C DOUBLE PRECISION RAPM
C DOUBLE PRECISION RAYDIR ( 3 )
C DOUBLE PRECISION RESULT ( LBCELL : MAXWIN )
C DOUBLE PRECISION RSTAR
C DOUBLE PRECISION STEPSZ
C DOUBLE PRECISION T
C
C INTEGER CATNO
C INTEGER I
C INTEGER J
C INTEGER N
C
C C
C C Load kernels.
C C
C CALL FURNSH ( META )
C
C C
C C Initialize windows.
C C
C CALL SSIZED ( MAXWIN, CNFINE )
C CALL SSIZED ( MAXWIN, RESULT )
C
C C
C C Insert search time interval bounds into the
C C confinement window.
C C
C CALL STR2ET ( '2004 JUN 11 06:30:00 TDB', ET0 )
C CALL STR2ET ( '2004 JUN 11 12:00:00 TDB', ET1 )
C
C CALL WNINSD ( ET0, ET1, CNFINE )
C
C C
C C Initialize inputs for the search.
C C
C INST = 'CASSINI_ISS_WAC'
C
C C
C C Create a unit direction vector pointing from
C c observer to star. We'll assume the direction
C C is constant during the confinement window, and
C C we'll use et0 as the epoch at which to compute the
C C direction from the spacecraft to the star.
C C
C C The data below are for the star with catalog
C C number 6000 in the Hipparcos catalog. Angular
C C units are degrees; epochs have units of Julian
C C years and have a reference epoch of J1950.
C C The reference frame is J2000.
C C
C CATNO = 6000
C
C PLXDEG = 0.000001056D0
C
C RADEG0 = 19.290789927D0
C RAPM = -0.000000720D0
C RAEPC = 41.2000D0
C
C DECDG0 = 2.015271007D0
C DECPM = 0.000001814D0
C DECEPC = 41.1300D0
C
C RFRAME = 'J2000'
C
C C
C C Correct the star's direction for proper motion.
C C
C C The argument t represents et0 as Julian years
C C past J1950.
C C
C T = ET0/JYEAR()
C . + ( J2000()- J1950() ) / 365.25D0
C
C DTRA = T - RAEPC
C DTDEC = T - DECEPC
C
C RADEG = RADEG0 + DTRA * RAPM
C DECDEG = DECDG0 + DTDEC * DECPM
C
C RA = RADEG * RPD()
C DEC = DECDEG * RPD()
C
C CALL RADREC ( 1.D0, RA, DEC, PSTAR )
C
C C
C C Correct star position for parallax applicable at
C C the Cassini orbiter's position. (The parallax effect
C C is negligible in this case; we're simply demonstrating
C C the computation.)
C C
C PARLAX = PLXDEG * RPD()
C RSTAR = AU / TAN(PARLAX)
C
C C
C C Scale the star's direction vector by its distance from
C C the solar system barycenter. Subtract off the position
C C of the spacecraft relative to the solar system barycenter;
C C the result is the ray's direction vector.
C C
C CALL VSCLIP ( RSTAR, PSTAR )
C
C CALL SPKPOS ( 'CASSINI', ET0, 'J2000', 'NONE',
C . 'SOLAR SYSTEM BARYCENTER', POS, LT )
C
C CALL VSUB ( PSTAR, POS, RAYDIR )
C
C C
C C Correct the star direction for stellar aberration when
C C we conduct the search.
C C
C ABCORR = 'S'
C OBSRVR = 'CASSINI'
C STEPSZ = 10.D0
C
C WRITE (*,*) ' '
C WRITE (*,*) 'Instrument: '//INST
C WRITE (*,*) 'Star''s catalog number: ', CATNO
C WRITE (*,*) ' '
C
C C
C C Perform the search.
C C
C CALL GFRFOV ( INST, RAYDIR, RFRAME, ABCORR,
C . OBSRVR, STEPSZ, CNFINE, RESULT )
C
C N = WNCARD( RESULT )
C
C IF ( N .EQ. 0 ) THEN
C
C WRITE (*,*) 'No FOV intersection found.'
C
C ELSE
C
C WRITE (*,*)
C . ' Visibility start time Stop time'
C
C DO I = 1, N
C
C CALL WNFETD ( RESULT, I, ENDPT(1), ENDPT(2) )
C
C DO J = 1, 2
C CALL TIMOUT ( ENDPT(J), TIMFMT, TIMSTR(J) )
C END DO
C
C LINE( :3) = ' '
C LINE(2: ) = TIMSTR(1)
C LINE(37:) = TIMSTR(2)
C
C WRITE (*,*) LINE
C
C END DO
C
C END IF
C
C WRITE (*,*) ' '
C END
C
C
C When this program was executed on a PC/Linux/g77 platform, the
C output was:
C
C
C Instrument: CASSINI_ISS_WAC
C Star's catalog number: 6000
C
C Visibility start time Stop time
C 2004-JUN-11 06:30:00.000000 (TDB) 2004-JUN-11 12:00:00.000000 (TDB)
C
C
C The star is visible throughout the confinement window.
C
C
C$ Restrictions
C
C The kernel files to be used by GFRFOV must be loaded (normally via
C the SPICELIB routine FURNSH) before GFRFOV is called.
C
C$ Literature_References
C
C None.
C
C$ Author_and_Institution
C
C N.J. Bachman (JPL)
C L.S. Elson (JPL)
C E.D. Wright (JPL)
C
C$ Version
C
C- SPICELIB Version 1.1.0 28-FEB-2012 (EDW)
C
C Implemented use of ZZHOLDD to allow user to alter convergence
C tolerance.
C
C Removed the STEP > 0 error check. The GFSSTP call includes
C the check.
C
C- SPICELIB Version 1.0.0 15-APR-2009 (NJB) (LSE) (EDW)
C
C-&
C$ Index_Entries
C
C GF ray in instrument FOV search
C
C-&
C$ Revisions
C
C None.
C
C-&
C
C SPICELIB functions
C
INTEGER SIZED
LOGICAL RETURN
C
C External routines
C
C
C Interrupt handler:
C
LOGICAL GFBAIL
EXTERNAL GFBAIL
C
C Routines to set step size, refine transition times
C and report work:
C
EXTERNAL GFREFN
EXTERNAL GFREPI
EXTERNAL GFREPU
EXTERNAL GFREPF
EXTERNAL GFSTEP
C
C Local parameters
C
C
C Geometric quantity bail switch:
C
LOGICAL BAIL
PARAMETER ( BAIL = .FALSE. )
C
C Progress report switch:
C
LOGICAL RPT
PARAMETER ( RPT = .FALSE. )
C
C Local variables
C
DOUBLE PRECISION TOL
LOGICAL OK
C
C Standard SPICE error handling.
C
IF ( RETURN () ) THEN
RETURN
END IF
CALL CHKIN ( 'GFRFOV' )
C
C Note to maintenance programmer: input exception checks
C are delegated to GFFOVE. If the implementation of that
C routine changes, or if this routine is modified to call
C a different routine in place of GFFOVE, then the error
C handling performed by GFFOVE will have to be performed
C here or in a routine called by this routine.
C
C Check the result window's size.
C
IF ( SIZED(RESULT) .LT. 2 ) THEN
CALL SETMSG ( 'Result window size must be at least 2 '
. // 'but was #.' )
CALL ERRINT ( '#', SIZED(RESULT) )
CALL SIGERR ( 'SPICE(WINDOWTOOSMALL)' )
CALL CHKOUT ( 'GFRFOV' )
RETURN
END IF
C
C Set the step size.
C
CALL GFSSTP (STEP)
C
C Retrieve the convergence tolerance, if set.
C
CALL ZZHOLDD ( ZZGET, GF_TOL, OK, TOL )
C
C Use the default value CNVTOL if no stored tolerance value.
C
IF ( .NOT. OK ) THEN
TOL = CNVTOL
END IF
C
C Look for solutions.
C
CALL GFFOVE ( INST, RYSHAP, RAYDIR, ' ', RFRAME, ABCORR,
. OBSRVR, TOL, GFSTEP, GFREFN, RPT, GFREPI,
. GFREPU, GFREPF, BAIL, GFBAIL, CNFINE, RESULT )
CALL CHKOUT ( 'GFRFOV' )
RETURN
END
|
C NAME: PI SPMD ... a simple version.
C This program will numerically compute the integral of
C 4/(1+x*x)
C from 0 to 1. The value of this integral is pi -- which
C is great since it gives us an easy way to check the answer.
C The program was parallelized using OpenMP and an SPMD
C algorithm. The following OpenMP specific lines were
C added:
C (1) A line to include omp.h -- the include file that
C contains OpenMP's function prototypes and constants.
C (2) A pragma that tells OpenMP to create a team of threads
C with an integer variable i being created for each thread.
C (3) two function calls: one to get the thread ID (ranging
C from 0 to one less than the number of threads), and the other
C returning the total number of threads.
C (4) A cyclic distribution of the loop by changing loop control
C expressions to run from the thread ID incremented by the number
C of threads. Local sums accumlated into sum[id].
C Note that this program will show low performance due to
C false sharing. In particular, sum(id) is unique to each
C thread, but adfacent values of this array share a cache line
C causing cache thrashing as the program runs.
C History: C code written by Tim Mattson, 11/1999
C Adapted to Fortran code by Helen He and Tim Mattson, 09/2017.
PROGRAM MAIN
USE OMP_LIB
IMPLICIT NONE
INTEGER i, j, id, numthreads, nthreads
INTEGER, PARAMETER :: num_steps=100000000
INTEGER, PARAMETER :: MAX_THREADS=4
REAL*8 pi, real_sum, step, full_sum, x
REAL*8 start_time, run_time
REAL*8 sum(0:MAX_THREADS-1)
full_sum = 0.0
step = 1.0/num_steps
start_time = OMP_GET_WTIME()
DO j=1,MAX_THREADS
CALL OMP_SET_NUM_THREADS(j)
full_sum = 0.0
start_time = omp_get_wtime()
!$OMP PARALLEL PRIVATE(id,x,numthreads)
id = omp_get_thread_num()
numthreads = OMP_GET_NUM_THREADS()
sum(id) = 0.0
IF (id == 0) THEN
nthreads = numthreads
ENDIF
DO i = id, num_steps-1, numthreads
x = (i+0.5)*step
sum(id) = sum(id) + 4.0/(1.0+x*x)
ENDDO
!$OMP END PARALLEL
full_sum = 0.0
DO i = 0, nthreads-1
full_sum = full_sum + sum(i)
ENDDO
pi = step * full_sum
run_time = OMP_GET_WTIME() - start_time
WRITE(*,100) pi, run_time, nthreads
100 FORMAT('pi is ',f15.8,' in ',f8.3,'secs and ',i3,' threads')
ENDDO
STOP
END
|
program TSPAN
c to test spantree.for
c If states i and j are connected then IC(1,m)=i, IC(2,m)=j, m=1,ncon
c IC is IC(2,ncon).
c May be easier to work with JCON(i,j)=0 if i,j not connected, =1 if connected
c where JCON(k,k), k=number of states (symmetric -only lower triangle needed)
integer IC(2,200),JCON(100,100)
integer ict(2,200) !IC for tree
integer jtree(100,100)
character*1,ans
integer NSC(50),IM(50,100),JM(50,100)
integer NSC1(50),IM1(50,100),JM1(50,100)
c for printing
character*40 mtitle1*40,filnam*32,prtport*4 !for WINPRINT
common/dpp/filnam,prtport,ndisc,jcol,mtitle1 !for WINPRINT,ENDPRINT,DISCNUM
logical discprt
common/dp/discprt
c
c
filnam='tspan.prt'
call WINPRINT !print file control
OPEN(unit=7,file=prtport,iostat=nerr) !open printer
c For cube
k=8
ncon=12
c front face =1,2,3,4
ic(1,1)=1
ic(2,1)=2
ic(1,2)=2
ic(2,2)=3
ic(1,3)=3
ic(2,3)=4
ic(1,4)=4
ic(2,4)=1
c back face =5,6,7,8
ic(1,5)=5
ic(2,5)=6
ic(1,6)=6
ic(2,6)=7
ic(1,7)=7
ic(2,7)=8
ic(1,8)=8
ic(2,8)=5
c front to back connections
ic(1,9)=1
ic(2,9)=6
ic(1,10)=2
ic(2,10)=7
ic(1,11)=3
ic(2,11)=8
ic(1,12)=4
ic(2,12)=5
c
c ===test subroutines
c do j=1,ncon
c print 30,j,ic(1,j),ic(2,j)
c write(8,30) j,ic(1,j),ic(2,j)
c30 format(1x,i2,3x,2i3)
c enddo
c nd1=200
c nd2=100
c call IC_JCON(IC,ncon,nd1,JCON,k,nd2)
c do i=1,k
c print 1,(jcon(i,j),j=1,k)
c if(discprt) write(8,1) (jcon(i,j),j=1,k)
cc1 format(20i3)
c enddo
c call JCON_IC(IC,ncon,nd1,JCON,k,nd2)
c do j=1,ncon
c print 30,j,ic(1,j),ic(2,j)
c write(8,30) j,ic(1,j),ic(2,j)
cc30 format(1x,i2,3x,2i3)
c enddo
c===end test
c
do i=1,k
do j=1,k
JCON(i,j)=0
c Jtree(i,j)=0
do m=1,ncon
if((IC(1,m).eq.i.and.IC(2,m).eq.j).or.
& (IC(1,m).eq.j.and.IC(2,m).eq.i)) JCON(i,j)=1
enddo
enddo
enddo
print 11
write(8,11)
11 format(' Connections for cube')
do i=1,k
print 1,(jcon(i,j),j=1,k)
if(discprt) write(8,1) (jcon(i,j),j=1,k)
1 format(20i3)
enddo
c
ndim=100
is1=1
20 print 10,k,is1
10 format(
& ' Starting state in search for tree (1 to ',i2,') [',i2,'] = ')
call INPUTi(is1)
call SPANTREE(JCON,Jtree,is1,k,ndim)
print 2
write(8,2)
2 format(/,/)
print 12,is1
write(8,12) is1
12 format(' Connections for spanning tree (start in state ',i3,')')
do i=1,k
print 1,(jtree(i,j),j=1,k)
if(discprt) write(8,1) (jtree(i,j),j=1,k)
c1 format(20i3)
enddo
c check which links are missing in the tree
nmr=0
ncont=0 !ncon for tree connections
c initialise ic() array for tree
do i=1,2
do j=1,100
ict(i,j)=0
enddo
enddo
c
do i=2,k !check lower triangle only
do j=1,i-1
if(jtree(i,j).eq.1) then
ncont=ncont+1
ict(1,ncont)=i
ict(2,ncont)=j
endif
enddo
enddo
ncmax=8 !max cycle size to be found
call CYCQ1(k,ncont,ict,ncyc,nsc0,im1,jm1,ncmax)
print 21,ncyc
write(8,21) ncyc
21 format(' Number of cycles in spanning tree = ',i3)
print 3
write(8,3)
3 format(/,' Links missing in tree (=MR routes)',/)
c
c To find cycle for each MR route (a) add that route (only) to JTREE(), and
c call CYCQ1 to find cycles in resulting structure -with luck get only one
c cycle -if more than one take the smallest
c To use original CYCQ need to convert the (modified) JTREE it the IC() form
c and find ncon for it.
c
do i=2,k !check lower triangle only
do j=1,i-1
if(jcon(i,j).eq.1.and.jtree(i,j).eq.0) then
nmr=nmr+1
c im(nmr,1)=i !set first im() to mr parameter
c jm(nmr,1)=j
print 4,nmr,i,j
write(8,4) nmr,i,j
4 format(/,' MR route ',i3,': i = ',i3,' j = ',i3)
c add the i,j route (only) to ICT() -the tree connections
ncont1=ncont+1
ict(1,ncont1)=i
ict(2,ncont1)=j
call CYCQ1(k,ncont1,ict,ncyc,nsc,im,jm,ncmax)
print 22,ncyc
write(8,22) ncyc
22 format(
& ' Number of cycles when this route added to tree = ',i3)
do n=1,ncyc
print 1311,im(n,1),jm(n,1)
if(discprt) write(8,1311)im(n,1),jm(n,1)
1311 format(2i3,' (calc by micro rev)')
print 128,(im(n,m),jm(n,m),m=2,nsc(n))
if(discprt) write(8,128)(im(n,m),jm(n,m),m=2,nsc(n))
128 format(2(5(2i3,4x),/))
enddo
endif
enddo
enddo
c
ans='Y'
call DCASK(' Try another starting state',ans,ans)
if(ans.eq.'Y') goto 20
c
end
subroutine IC_JCON(IC,ncon,nd1,JCON,k,nd2)
c Converts connections from IC(2,ncon) form to JCON(k,k) form
c Input IC, ncon,k
c Output JCON
integer*4 IC(2,nd1),JCON(nd2,nd2)
c
do i=1,nd2
do j=1,nd2
JCON(i,j)=0
enddo
enddo
c
do i=1,k
do j=1,k
do m=1,ncon
if((IC(1,m).eq.i.and.IC(2,m).eq.j).or.
& (IC(1,m).eq.j.and.IC(2,m).eq.i)) JCON(i,j)=1
enddo
enddo
enddo
RETURN
end
subroutine JCON_IC(IC,ncon,nd1,JCON,k,nd2)
c Converts connections from JCON(k,k) form to IC(2,ncon) form
c Input JCON,k
c Output IC, ncon
integer*4 IC(2,nd1),JCON(nd2,nd2)
c
do i=1,2
do j=1,nd1
IC(i,j)=0
enddo
enddo
c
ncon=0
do i=1,k-1 !check upper triangle only
do j=i+1,k
if(jcon(i,j).eq.1) then
ncon=ncon+1
ic(1,ncon)=i
ic(2,ncon)=j
endif
enddo
enddo
c do i=2,k !check lower triangle only
c do j=1,i-1
c if(jcon(i,j).eq.1) then
c ncon=ncon+1
c ic(1,ncon)=i
c ic(2,ncon)=j
c endif
c enddo
c enddo
RETURN
end
|
* lpair_photos.f =====================================================
* By A. Shamov
* PHOTOS control in LPAIR
* call lpair_photos(flags,omegamin)
* integer flags = 1 - radiation off muon lines
* 2 - radiation off proton lines
* 3 - both
*=====================================================================
subroutine lpair_photos(flags,omegamin)
implicit none
*--------------------------------------------------------------------
integer flags
real omegamin
c
integer PHOTOSon
real PHOTomegaMin
common /photosonoff/ PHOTOSon,PHOTomegaMin
c
integer kPHOT
*--------------------------------------------------------------------
c
kPHOT=mod(flags,10)
if(kPHOT.ne.0) then
PHOTOSon=flags
print *
if(kPHOT.ne.2)
& print *,'LPAIR_PHOTOS: raiation off muon lines is on'
if(kPHOT.ge.2)
& print *,'LPAIR_PHOTOS: raiation off proton lines is on'
print *
else
print *
print *,'LPAIR_PHOTOS: real photon radiation is off'
print *
PHOTOSon=0
endif
if(omegamin.gt.0.) PHOTomegaMin=omegamin
c
end
|
subroutine copy_32_to_64(n, a32, a64)
implicit none
!
integer, parameter :: sp = selected_real_kind(6, 37)
integer, parameter :: dp = selected_real_kind(15, 307)
!
integer, intent(in) :: n
real(kind=sp), intent(in) :: a32(n)
real(kind=dp), intent(out) :: a64(n)
!
integer :: i
#ifdef GNU_GE_4_8
do concurrent (i=1:n)
#else
do i=1,n
#endif
a64(i) = real(a32(i), kind=dp)
end do
end subroutine
subroutine copy_64_to_32(n, a64, a32)
implicit none
!
integer, parameter :: sp = selected_real_kind(6, 37)
integer, parameter :: dp = selected_real_kind(15, 307)
!
integer, intent(in) :: n
real(kind=dp), intent(in) :: a64(n)
real(kind=sp), intent(out) :: a32(n)
!
integer :: i
#ifdef GNU_GE_4_8
do concurrent (i=1:n)
#else
do i=1,n
#endif
a32(i) = real(a64(i), kind=sp)
end do
end subroutine
subroutine add_32_to_64(n, a32, a64)
implicit none
!
integer, parameter :: sp = selected_real_kind(6, 37)
integer, parameter :: dp = selected_real_kind(15, 307)
!
integer, intent(in) :: n
real(kind=sp), intent(in) :: a32(n)
real(kind=dp), intent(inout) :: a64(n)
!
integer :: i
#ifdef GNU_GE_4_8
do concurrent (i=1:n)
#else
do i=1,n
#endif
a64(i) = a64(i) + real(a32(i), kind=dp)
end do
end subroutine
subroutine add_64_to_32(n, a64, a32)
implicit none
!
integer, parameter :: sp = selected_real_kind(6, 37)
integer, parameter :: dp = selected_real_kind(15, 307)
!
integer, intent(in) :: n
real(kind=dp), intent(in) :: a64(n)
real(kind=sp), intent(inout) :: a32(n)
!
integer :: i
#ifdef GNU_GE_4_8
do concurrent (i=1:n)
#else
do i=1,n
#endif
a32(i) = a32(i) + real(a64(i), kind=sp)
end do
end subroutine
|
c$pragma c setres
C$PRAGMA C (GETUNO)
C MODULE RSFILE
C-----------------------------------------------------------------------
C Routine to reserve a file unit number for later use.
C-----------------------------------------------------------------------
C notes: (1) This subroutine does not open the file. It just
C reserves a unit number for the file.
C (2) Once a unit number has been reserved, it CANNOT be
C used to open a file. This function is designed to
C "lock out" unit numbers from use. In particular, it
C is used to reserve unit numbers that are in the middle
C of a range of available unit numbers. The ability to
C open a reserved file may be added in the future. This
C requires saving information about the unit number, like
C the "key".
C (3) Unit numbers are set in the FILEUNIT file under the
C NWSRFS system files.
C (4) The NWSRFS "IFILES" array is used to indicate the
C status of a file. Originally, the flags for this
C variable were:
C 0 = file unused
C 1 = file is direct access
C 2 = file is sequential
C In order to add the capability to reserve files, the
C "IFILES" variable is treated as a bit mask, where the
C above values apply and additionally:
C 4 = file is reserved
C (5) One-word Fortran strings that are used must end in a
C space. The space will be replaced with a NULL by any
C C routines that are called.
C (6) It is assumed that unit number zero can be used for
C standard error only.
C-----------------------------------------------------------------------
C variables:
C
C filekeys .... array of "key" values for use in other routines
C i .... loop counter
C ierr .... error status variable (1 if error, 0 if not)
C ifiles .... array used to indicate file status (taken from
C "ufiles"common block)
C istderr .... unit number for standard error (taken from "sionum"
C common block)
C key .... keyword that is used to look up unit number for
C file last letter as passed in must be a space)
C mfiles .... size of "ifiles" array (taken from "ufiles" common
C block)
C pgmnam .... name of the program that is reserving the file
C (taken from the "upvrsx" common block)
C setres .... function to reserve unit number
C istatus .... return status
C iunit .... unit number that will be reserved for "key"
C-----------------------------------------------------------------------
subroutine rsfile ( key, iunit, ierr )
include 'ufiles'
include 'upvrsx'
include 'common/ionum'
include 'common/fdbug'
include 'common/sionum'
include 'common/unitno'
include 'common/where'
character*(*) key
integer setres
C
C ================================= RCS keyword statements ==========
CHARACTER*68 RCSKW1,RCSKW2
DATA RCSKW1,RCSKW2 / '
.$Source: /fs/hseb/ob72/rfc/calb/src/gen/RCS/rsfile.f,v $
. $', '
.$Id: rsfile.f,v 1.4 2002/02/11 13:29:33 michaelo Exp $
. $' /
C ===================================================================
C
call umemov ('RSFILE ',opname,2)
if ( itrace .ge. 1 ) write (iodbug,*) 'ENTER RSFILE'
ierr = 0
C get the unit number to use for the file...
call getuno ( mfiles, ifiles, pgmnam, key, iunit, ierr )
if ( ierr .ne. 0 ) then
write (istderr,20) key(1:lenstr(key))
20 format ('0**ERROR** Unable to get unit number for key ',a,'.')
ierr = 1
go to 99
endif
C reserve the unit number
if ( iunit .gt. 0 ) then
istatus = setres ( ifiles(iunit) )
if ( istatus .ne. 0 ) then
write (istderr,40) iunit, key(1:lenstr(key))
40 format('0**ERROR** Unable to reserve unit number ',i3,
+ ' for key ',a,'.')
ierr = 1
go to 99
endif
endif
C save key
filekeys(iunit) = key
99 if ( itrace .ge. 1 ) write (iodbug,*) 'EXIT RSFILE'
return
end
|
C %W% %G%
subroutine hotchg
C process /CHANGE_BUS_TYPES commands.
include 'ipfinc/parametr.inc'
include 'ipfinc/alpha.inc'
include 'ipfinc/arcntl.inc'
include 'ipfinc/area.inc'
include 'ipfinc/blank.inc'
include 'ipfinc/branch.inc'
include 'ipfinc/bus.inc'
include 'ipfinc/cbsorc.inc'
include 'ipfinc/cbus.inc'
include 'ipfinc/coment.inc'
include 'ipfinc/ecvar.inc'
include 'ipfinc/ikk.inc'
include 'ipfinc/intbus.inc'
include 'ipfinc/lfiles.inc'
include 'ipfinc/lndpcp.inc'
include 'ipfinc/ordsta.inc'
include 'ipfinc/prt.inc'
include 'ipfinc/qsdup.inc'
include 'ipfinc/slnopt.inc'
include 'ipfinc/snput.inc'
include 'ipfinc/tbx.inc'
include 'ipfinc/tran.inc'
include 'ipfinc/xdata.inc'
include 'ipfinc/basval.inc'
include 'ipfinc/miscfile.inc'
common /is_batch / is_batch
integer find_bus, error, findex, ptr, num_delltcs, offset,
& inpold
character bs_code*1, bus1*8, word(100)*60, capital*132,
& bigbuf*512, comprs*512, tag*24, word2(10)*60,
& tempfilename*60
logical found, chgbrn, plist, finished_1, finished_2
real cv(1), ci(1), cz(1)
external find_bus
tbx_loaded = 0
xdt_flag = .false.
plist = .true.
c*** Fix for base cases prior to version 4 (lskp is now set in rddtai)
if ( lskp .ne. 1 .and. basval(8)(1:2) .eq. 'PF') then
write (errbuf(1), 11)
11 format(' CHANGE_BUS_TYPES is illegal with vintage PF60xx ',
& 'base cases (history files) --')
write (errbuf(2), 12)
12 format(' unless the case is resolved with the new IPF/BPF',
& ' version.')
write (errbuf(3), 13)
13 format(' / CHANGE_BUS_TYPES command ignored.')
if (is_batch .eq. 0) then
call prterx ('E',3)
else
call prterx ('F',3)
endif
return
elseif ( lskp .ne. 1) then
write (errbuf(1), 21)
21 format(' CHANGE_BUS_TYPES is invalid with a failed solution in
& the base case history file.')
write (errbuf(2), 22)
22 format(' Regenerate the base case to start with a solved base c
&ase')
write (errbuf(3), 23)
23 format(' / CHANGE_BUS_TYPES command ignored.')
if (is_batch .eq. 0) then
call prterx ('E',3)
else
call prterx ('F',3)
endif
return
endif
chgbrn = .false.
num_delltcs = 0
C / CHANGE_BUS_TYPES, BQ=B, LTC=OFF, AREAS=<area_1,...>,
C BG=BQ,
C BG=B ,
C BQ=BF ,
C BT=B ,
C BX=B ,
C BX=BF,
C ZONES=<zone_1,...>
C LIST=ON
C > EXCLUDE_BUSES
C B bus_name bkv
C B bus_name bkv
C
C > LINE_DROP_COMPENSATORS
C BG bus_name bkv, ##%
C BG bus_name bkv, ##%
C
C > REACTIVE_COMPENSATION
C BG bus_name bkv, ##%, ##
C BG bus_name bkv, ##%, ##
call space (1)
write (outbuf,90 ) buf(1:80)
90 format (' CHANGE_BUS_TYPES text: (',a,')')
call prtout (1)
inpold = inp
buf = capital(buf)
if (index (buf,'CHANGE_BUS') .ne. 0 .or.
1 index (buf,'CHANGEBUS') .ne. 0) then
C
C Check for and concatenate continuation records.
C
bigbuf = comprs (buf)
298 last = lastch (bigbuf)
if (bigbuf(last:last) .eq. '-') then
read (inp, 260, end=261) buf
260 format (a)
call space (1)
write (outbuf,90) buf(1:80)
call prtout (1)
buf = capital(buf)
bigbuf(last:) = comprs(buf)
go to 298
261 buf = '( END ) HOTCHG'
card = buf(1:1)
endif
call uscan(bigbuf, word, nwrd, '=', ' ,/\\<>()')
jwrd = nwrd
C
C Initialize IKK array:
C
C (1,*) (not used)
C (2,*) = 0 : bus is not eligible for type change.
C 1 : bus is eligible for type change.
C 2 : (generation is dropped, therefore ineligible
C for allocation)
C (3,*) = I (cross index to TBX array)
C (4,*) = NC (forced BG -> BG retention because of line drop
C compensation)
C (5,*) = J (LTC index of controlled bus)
C
do nb = 1, ntot
ikk(1,nb) = 0
ikk(2,nb) = 1
ikk(3,nb) = 0
ikk(4,nb) = 0
ikk(5,nb) = 0
enddo
c
c Load LINE_DROP_COMPENSATION from any prior /CHANGE_BUS_TYPE
c
do i = 1, numldc
nb = lndpcp(1,i)
ikk(4,nb) = i
enddo
do i = 1, ntotb
ltyp = tbx(1,i)
if (ltyp .lt. 10) then
nb = tbx(2,i)
if (ordtbx .eq. 2) nb = opt2inp(nb)
ikk(3,nb) = i
endif
enddo
do i = 1, ntota
ltyp = mod (ltran(10,i), 10)
if (ltyp .eq. 1 .or. ltyp .eq. 2 .or. ltyp .eq. 4) then
kc = ltran(2,i)
if (kc .eq. -1) then
nb = ltran(1,i)
else if (kc .eq. -2) then
nb = ltran(9,i)
else if (kc .gt. 0) then
nb = kc
else
nb = ltran(1,i)
endif
C
C If NB is already controlled by a different LTC,
C flag the opposite terminal as LTC controlled.
C
if (ikk(5,nb) .eq. 0) then
else if (nb .eq. ltran(1,i)) then
nb = ltran(9,i)
else
nb = ltran(1,i)
endif
if (ordltc .eq. 2) nb = opt2inp(nb)
ikk(5,nb) = i
else
nb = ltran(1,i)
C
C If NB is already controlled by a different LTC,
C flag the opposite terminal as LTC controlled.
C
if (ikk(5,nb) .ne. 0) then
nb = ltran(9,i)
endif
if (ordltc .eq. 2) nb = opt2inp(nb)
ikk(5,nb) = i
endif
enddo
C
C Search for FILE = <file_name>
C
i = 1
finished_1 = (i .ge. jwrd)
do while (.not. finished_1)
if (word(i)(1:4) .eq. 'FILE') then
C
C Check for "=" separator.
C
if (word(i+1) .ne. '=') then
last = lastch (word(i))
write (errbuf(1), 84) word(i)(1:last)
84 format('Keyword (',a,') in / CHANGE_BUS_TYPES ',
& 'text is not followed with an "=" sign.')
call prterx ('W', 1)
next = i + 1
else
next = i + 2
endif
finished_1 = .true.
tempfilename = word(next)
inpold = inp
inp = lunscr1
ierror = 0
call opnfil(inp, tempfilename, ierror)
if (ierror .ne. 0) inp = inpold
offset = next - i + 1
do j = next+1, jwrd
word(j-offset) = word(j)
enddo
jwrd = jwrd - offset
nwrd = jwrd
else
i = i + 1
finished_1 = (i .ge. jwrd)
endif
enddo
C
C Search for LIST = ON
C
i = 1
finished_1 = (i .ge. jwrd)
do while (.not. finished_1)
if (word(i)(1:4) .eq. 'LIST') then
C
C Check for "=" separator.
C
if (word(i+1) .ne. '=') then
last = lastch (word(i))
write (errbuf(1), 84) word(i)(1:last)
call prterx ('W', 1)
next = i + 1
else
next = i + 2
endif
finished_1 = .true.
if (word(next) .eq. 'OFF') plist = .false.
offset = next - i + 1
do j = next+1, jwrd
word(j-offset) = word(j)
enddo
jwrd = jwrd - offset
nwrd = jwrd
else
i = i + 1
finished_1 = (i .ge. jwrd)
endif
enddo
C
C Search for AREAS = <area_1,...>
C
do i = 1, jwrd
if (word(i)(1:4) .eq. 'AREA') then
nwrd = i - 1
C
C Check for "=" separator.
C
if (word(i+1) .ne. '=') then
last = lastch (word(i))
write (errbuf(1), 84) word(i)(1:last)
call prterx ('W', 1)
next = i + 1
else
next = i + 2
endif
do nb = 1, ntot
ikk(2,nb) = 0
enddo
do j = next, jwrd
do k = 1, ntotc
if (arcnam(k) .eq. word(j)) then
do nb = 1, ntot
if (jarzn(nb) .eq. k) then
ikk(2,nb) = 1
endif
enddo
go to 350
endif
enddo
last = lastch (word(j))
write (errbuf(1), 340) word(j)(1:last)
340 format('Interchange area (',a,') is not in system')
call prterx ('W', 1)
350 continue
enddo
go to 410
else if (word(i)(1:4) .eq. 'ZONE') then
nwrd = i - 1
C
C Check for "=" separator.
C
if (word(i+1) .ne. '=') then
last = lastch (word(i))
write (errbuf(1), 84) word(i)(1:last)
call prterx ('W', 1)
next = i + 1
else
next = i + 2
endif
do nb = 1, ntot
ikk(2,nb) = 0
enddo
do j = next, jwrd
found = .false.
do nb = 1, ntot
if (zone(nb) .eq. word(j)) then
ikk(2,nb) = 1
found = .true.
endif
enddo
if (.not.found) then
last = lastch (word(j))
write (errbuf(1), 380) word(j)(1:last)
380 format('Zone (',a,') is not in system')
call prterx ('W', 1)
endif
enddo
go to 410
endif
enddo
410 continue
C
C Read next card, check for >EXCLUDE qualifier.
C
10250 read (inp, 260, end=10450) buf
call space (1)
write (outbuf, 90) buf(1:80)
call prtout (1)
finished_1 = .false.
do while (.not. finished_1)
card = buf(1:1)
if (card .eq. '.') then
read (inp, 260, end=10450) buf
write (outbuf, 90) buf(1:80)
call prtout (1)
else if (card .eq. '>') then
if (findex(buf(2:10),'EXCLUDE') .ne. 0) then
C
C > EXCLUDE_BUSSES <
C
finished_2 = .false.
do while (.not. finished_2)
read (inp, 260, end=10450) buf
card = buf(1:1)
call space (1)
write (outbuf, 90) buf(1:80)
call prtout (1)
if (card .eq. '.') then
else if (card .eq. 'B') then
read (buf, 10280) bus1, base1
10280 format (bz, t7, a8, f4.0)
nb = find_bus (bus1, base1)
if (nb .le. 0) then
write (errbuf(1),10290) bus1, base1
10290 format ('EXCLUDE_BUS (', a8, f6.1,
& ') is not in system.')
call prterx ('W', 1)
else
ikk(2,nb) = 0
endif
else
finished_2 = .true.
endif
enddo
else if (findex(buf(2:10),'LINE') .ne. 0 .or.
& findex(buf(2:10),'REACTIVE') .ne. 0) then
C
C > LINE_DROP_COMPENSATORS
C > REACTIVE_COMPENSATION
C
call uscan(buf(2:), word2, nwrd2, '=', ' ,')
tag = word2(1)
last = lastch (tag)
finished_2 = .false.
do while (.not. finished_2)
read (inp, 260, end=10450) buf
card = buf(1:1)
call space (1)
write (outbuf, 90) buf(1:80)
call prtout (1)
if (card .eq. '.') then
else if (card .eq. 'B') then
read (buf, 10294) bus1, base1
10294 format (bz, t7, a8, f4.0)
nb = find_bus (bus1, base1)
error = 0
if (nb .le. 0) then
write (errbuf(1), 10296) tag(1:last), bus1, base1
10296 format (a, ' bus (', a8, f6.1,
1 ') is not in system.')
call prterx ('W', 1)
error = 1
else if (kbsdta(1,nb) .eq. 8) then
ikk(4,nb) = numldc + 1
mb = kbsdta(13,nb)
if (mb .eq. 0 .or. mb .eq. nb) then
ptr = kbsdta(16,nb)
mb = ky(ptr)
else
ptr = kbsdta(16,nb)
found = .false.
do while (ptr .gt. 0 .and. .not. found)
if (ky(ptr) .eq. mb) then
found = .true.
else
ptr = brnch_nxt(ptr)
endif
enddo
if (.not. found) then
write (errbuf(1), 10300) tag(1:last), bus1,
& base1, bus(mb), base(mb)
10300 format (a, ' bus (', a8, f6.1,
1 ') is controlling a remote bus (', a8,
2 f6.1, ')')
call prterx ('W', 1)
error = 1
endif
endif
else
call typno (bs_code, kbsdta(1,nb))
write (errbuf(1), 10304) tag(1:last), bus1,
& base1, 'B'//bs_code
10304 format (a, ' (', a8, f6.1,
1 ') is illegal type "', a, '".')
call prterx ('W', 1)
error = 1
endif
if (error .eq. 0) then
call uscan(buf(20:), word2, nwrd2, '=', ' ,%')
pct = ftn_atof (word2(1))
if (pct .le. 0.0 .or. pct .gt. 100.0) then
write (errbuf(1), 10310) tag(1:last), bus1,
& base1, pct
10310 format (a, ' bus (', a8, f6.1,
& ') has an unconventional percentage (', f6.1,
& ')')
call prterx ('W', 1)
endif
do i = 1, numldc
if (lndpcp(1,i) .eq. nb) then
write (errbuf(1), 10312) tag(1:last), bus1,
& base1
10312 format ('Duplicate ', a, ' buses (',
& a8, f6.1, ') ignored.)')
call prterx ('W', 1)
go to 10318
endif
enddo
if (numldc .ge. 20) then
write (errbuf(1), 10316) 20, tag(1:last), bus1,
& base1
10316 format ('More than ', i3, 1x, a,
& ' records. Bus (', a8, f6.1, ') ignored.)')
call prterx ('W', 1)
else
numldc = numldc + 1
lndpcp(1,numldc) = nb
drppct(numldc) = pct / 100.0
kt = inp2opt(nb)
vk = dsqrt (e(kt) ** 2 + f(kt) ** 2)
if (tag(1:4) .eq. 'LINE') then
lndp_type(numldc) = 1
lndpcp(2,numldc) = mb
c
c Compute voltage
c
mt = inp2opt(mb)
vm = dsqrt (e(mt) ** 2 + f(mt) ** 2)
vmax_ldc(numldc) = drppct(numldc) * vk
& + (1.0 - drppct(numldc)) * vm
vmin_ldc(numldc) = vmax_ldc(numldc)
xc_ldc(numldc) = 0.0
else
lndp_type(numldc) = 2
lndpcp(2,numldc) = 0
xbase = ftn_atof (word2(2))
if (xbase .eq. 0.0) xbase = bmva
xc_ldc(numldc) = 0.01 * pct * bmva / xbase
cz(1) = xc_ldc(numldc)
ci(1) = qnetu(kt) / vk
cv(1) = vk - ci(1) * cz(1)
vmax_ldc(numldc) = cv(1)
vmin_ldc(numldc) = cv(1)
endif
endif
endif
else
finished_2 = .true.
endif
10318 continue
enddo
else
write (errbuf(1), 10430) buf(1:20)
10430 format('Unrecognized /CHANGE_BUS_TYPE command (',
1 a,').')
call prterx ('W', 1)
endif
else
finished_1 = .true.
endif
enddo
go to 10453
10450 buf = '( END ) HOTCHG'
card = buf(1:1)
10453 if (inp .ne. inpold) then
inp = inpold
read (inp, 260, end=10451) buf
go to 10452
10451 buf = '( END ) HOTCHG'
10452 card = buf(1:1)
endif
C
C Write header
C
call forbtm
write (outbuf, 10454)
10454 format (t53, ' Summary of /CHANGE_BUS_TYPES Conversion ')
call shdlod(1)
write (outbuf, 411)
411 format ('0BUS', t18, 'LTC disabled?', t34, 'Zone',
1 t40, 'Bus Type', t50, '-- Shunt (MVAR) --',
2 t72, '-- Generation (MVAR) --',
3 t98, '-- Voltage Original Final --')
call shdlod(2)
write (outbuf, 412)
412 format (t40, 'old new', t48, ' Orig Final Removed',
1 t72, ' Orig Min Max Removed',
2 t98, ' Vact Vmin Vmax Vmin Vmax')
call shdlod(3)
outbuf = ' '
call shdlod(4)
call shdlod(5)
call fortop
C
C First pass. Convert type BG LINE_DROP_COMPENSATOR and type
C BG REACTIVE_COMPSENSATION generators to type BG, controlling
C themselves.
C
do i = 1, numldc
nb = lndpcp(1,i)
if (ikk(4,nb) .ne. 0) then
kt = inp2opt(nb)
jtbx = ikk(3,nb)
jltc = ikk(5,nb)
kbsdta(13,nb) = nb
if (ordtbx .eq. 1) then
tbx(8,jtbx) = nb
else
tbx(8,jtbx) = kt
endif
C
C Reset type conversion flag to prevent duplicate
C type change.
C
ikk(2,nb) = 0
endif
enddo
do i = 2, nwrd, 3
if (word(i) .eq. 'BQ') then
C
C Check for "=" separator.
C
if (word(i+1) .ne. '=') then
last = lastch (word(i))
write (errbuf(1), 84) word(i)(1:last)
if (is_batch .eq. 0) then
call prterx ('E',1)
else
call prterx ('F',1)
endif
endif
C
C BQ --> B* unconditionally.
C BQ --> B if PGEN, QGEN, or QGEN_limits = 0.
C BQ --> BQ otherwise.
C
if (word(i+2) .eq. 'B ' .or. word(i+2) .eq. 'B*') then
do nb = 1, ntot
if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 7)
1 then
kt = inp2opt(nb)
jtbx = ikk(3,nb)
jltc = ikk(5,nb)
qmach = busdta(9,nb) - busdta(10,nb)
if (abs (qmach) .le. 0.5 .or.
1 word(i+2) .eq. 'B*') then
call chgbty (nb, 1, jtbx, jltc, plist)
else
call chgbty (nb, 7, jtbx, jltc, plist)
endif
endif
enddo
else if (word(i+2) .eq. 'BF' .or. word(i+2) .eq. 'BF*')
1 then
C
C BQ --> BF* unconditionally.
C BQ --> BF if PGEN, QGEN, or QGEN_limits = 0.
C BQ --> BQ otherwise.
C
do nb = 1, ntot
if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 7)
1 then
kt = inp2opt(nb)
jtbx = ikk(3,nb)
jltc = ikk(5,nb)
vksq = e(kt) ** 2 + f(kt) ** 2
qmach = busdta(9,nb) - busdta(10,nb)
if (abs (qmach) .le. 0.5 .or.
1 word(i+2) .eq. 'BF*') then
call chgbty (nb, 1, jtbx, jltc, plist)
else
call chgbty (nb, 7, jtbx, jltc, plist)
endif
endif
enddo
else
write (errbuf(1), 420) word(i), word(i+2)
420 format('Illegal bus type conversion (', a2,') > (',
1 a2,') ignored')
if (is_batch .eq. 0) then
call prterx ('E',1)
else
call prterx ('F',1)
endif
go to 440
endif
else if (word(i) .eq. 'BG') then
C
C BG --> BQ* unconditionally.
C BG --> BQ if PGEN, QGEN, or QGEN_limits = 0.
C
C Check for "=" separator.
C
if (word(i+1) .ne. '=') then
last = lastch (word(i))
write (errbuf(1), 84) word(i)(1:last)
if (is_batch .eq. 0) then
call prterx ('E',1)
else
call prterx ('F',1)
endif
endif
if (word(i+2) .eq. 'BQ' .or. word(i+2) .eq. 'BQ*') then
do nb = 1, ntot
if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 8)
1 then
kt = inp2opt(nb)
jtbx = ikk(3,nb)
jltc = ikk(5,nb)
qmach = busdta(9,nb) - busdta(10,nb)
if (abs (qmach) .le. 0.5 .or.
1 word(i+2) .eq. 'BQ*') then
call chgbty (nb, 1, jtbx, jltc, plist)
else
call chgbty (nb, 7, jtbx, jltc, plist)
endif
endif
enddo
else if (word(i+2) .eq. 'B ' .or. word(i+2) .eq. 'B*')
1 then
C
C BG --> B* unconditionally.
C BG --> B if PGEN, QGEN, or QGEN_limits = 0.
C
do nb = 1, ntot
if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 1)
1 then
kt = inp2opt(nb)
jtbx = ikk(3,nb)
jltc = ikk(5,nb)
qmach = busdta(9,nb) - busdta(10,nb)
if (abs (qmach) .le. 0.5 .or.
1 word(i+2) .eq. 'BQ*') then
call chgbty (nb, 1, jtbx, jltc, plist)
endif
endif
enddo
else if (word(i+2) .eq. 'BF' .or. word(i+2) .eq. 'BF*')
1 then
C
C BG --> BF* unconditionally.
C BG --> BF if PGEN, QGEN, or QGEN_limits = 0.
C
do nb = 1, ntot
if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 7)
1 then
kt = inp2opt(nb)
jtbx = ikk(3,nb)
jltc = ikk(5,nb)
qmach = busdta(9,nb) - busdta(10,nb)
if (abs (qmach) .le. 0.5 .or.
1 word(i+2) .eq. 'BQ*') then
call chgbty (nb, 13, jtbx, jltc, plist)
endif
endif
enddo
else
write (errbuf(1), 420) word(i), word(i+2)
if (is_batch .eq. 0) then
call prterx ('E',1)
else
call prterx ('F',1)
endif
go to 440
endif
else if (word(i) .eq. 'BT') then
C
C BT --> B
C
C Check for "=" separator.
C
if (word(i+1) .ne. '=') then
last = lastch (word(i))
write (errbuf(1), 84) word(i)(1:last)
if (is_batch .eq. 0) then
call prterx ('E',1)
else
call prterx ('F',1)
endif
endif
if (word(i+2) .eq. 'B ') then
C
C Set flag to compress BRNCH array.
C
do nb = 1, ntot
if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 10)
1 then
jtbx = ikk(3,nb)
jltc = ikk(5,nb)
if (jltc .eq. 0) then
write (errbuf(1), 10425) bus(nb), base(nb),
1 word(i), word(i+2)
10425 format(' Bus ', a8, f6.1,
& ' type is changed from (', a2,') to (',
& a2, ') but has no LTC control.')
call prterx ('W', 1)
else
chgbrn = .true.
call chgbty (nb, -1, jtbx, jltc, plist)
endif
endif
enddo
else
write (errbuf(1), 420) word(i), word(i+2)
if (is_batch .eq. 0) then
call prterx ('E',1)
else
call prterx ('F',1)
endif
go to 440
endif
else if (word(i) .eq. 'BX') then
C
C BX --> B
C BX --> B*
C
C Check for "=" separator.
C
if (word(i+1) .ne. '=') then
last = lastch (word(i))
write (errbuf(1), 84) word(i)(1:last)
if (is_batch .eq. 0) then
call prterx ('E',1)
else
call prterx ('F',1)
endif
endif
if (word(i+2) .eq. 'B ' .or. word(i+2) .eq. 'B*') then
do nb = 1, ntot
if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 11)
1 then
jtbx = ikk(3,nb)
jltc = ikk(5,nb)
call chgbty (nb, 1, jtbx, jltc, plist)
endif
enddo
else if (word(i+2) .eq. 'BF' .or. word(i+2) .eq. 'BF*')
1 then
C
C BX --> BF
C BX --> BF*
C
do nb = 1, ntot
if (ikk(2,nb) .eq. 1 .and. kbsdta(1,nb) .eq. 11)
1 then
jtbx = ikk(3,nb)
jltc = ikk(5,nb)
call chgbty (nb, 13, jtbx, jltc, plist)
endif
enddo
else
write (errbuf(1), 420) word(i), word(i+2)
if (is_batch .eq. 0) then
call prterx ('E',1)
else
call prterx ('F',1)
endif
go to 440
endif
else if (word(i) .eq. 'LTC') then
C
C LTC --> OFF
C
C
C Check for "=" separator.
C
if (word(i+1) .ne. '=') then
last = lastch (word(i))
write (errbuf(1), 84) word(i)(1:last)
if (is_batch .eq. 0) then
call prterx ('E',1)
else
call prterx ('F',1)
endif
endif
if (word(i+2) .eq. 'OFF') then
C
C Set flag to compress BRNCH array.
C
do nb = 1, ntot
if (ikk(2,nb) .eq. 1 .and. ikk(5,nb) .gt. 0) then
jtbx = ikk(3,nb)
ktyp = kbsdta(1,nb)
jltc = ikk(5,nb)
C
C Exclude d-c commutating LTC's.
C Changing a bus type to itself is a magic
C code to delete a connected LTC.
C
if (ktyp .ne. 5 .and. ktyp .ne. 12) then
chgbrn = .true.
num_delltcs = num_delltcs + 1
call chgbty (nb, -ktyp, jtbx, jltc, plist)
endif
endif
enddo
else
write (errbuf(1), 10427) word(i), word(i+2)
10427 format('Illegal LTC option (', a3,') > (',
1 a6,') ignored')
if (is_batch .eq. 0) then
call prterx ('E',1)
else
call prterx ('F',1)
endif
go to 440
endif
else
write (errbuf(1), 430) word(i), word(i+2)
430 format('Unrecognized bus type conversion (', a2,') > (',
1 a2,') ignored')
if (is_batch .eq. 0) then
call prterx ('E',1)
else
call prterx ('F',1)
endif
go to 440
endif
440 continue
enddo
else
write (errbuf(1),180 )
180 format('Illegal / CHANGE_BUS_TYPES command.')
errbuf(2) = ' '
write (errbuf(3),182) buf(1:80)
182 format (' (',a80,')')
if (is_batch .eq. 0) then
call prterx ('E',1)
else
call prterx ('F',1)
endif
return
endif
if (num_delltcs .gt. 0) then
write (outbuf, 736) num_delltcs/2
736 format ('0 / CHANGE_BUS_TYPES has deleted ', i3,
1 ' LTC''s from system')
endif
outbuf = ' '
call shdlod (1)
call shdlod (2)
call shdlod (3)
call shdlod (4)
call shdlod (5)
outbuf = '0End of /CHANGE_BUS_TYPE'
call prtout(1)
call forbtm
return
end
|
SUBROUTINE WRTMAP55(PO,NB,MPRV,XXLAT,XXLON,Y,HS,BS,BSS,X,HLV,
. NJFM,NIFM,NJTO,NITO,NQL,LQ1,LQN,MPLOC,JCK,IMAP,MRV,NJUN,NSTR,
. NST,STONAM,GZO,DTMAP,DTH,IOPNMAP,
. K1,K2,K9,K10,K14,K22,K27,K30)
c this subroutine writes out the data needed for FLDVIEW
c data is written to four files:
c (1) scenario info, cross section info - rvr mile, invert, lat, long
c (2) wsel profile - rvr mile, peak wsel, topwidth, wsel on town side of levee
c (3) same as (2) for animation; one file per animation step
c (4) cross section info - rvr mile, t.s. id, b vs h curve
c... MPFRST=0 => initialize everything
c... 1 => animation mode; store at selected time step
c... 2 => animation mode; done with time step, store peak
C
C ROUTINE WAS WRITTEN ORIGINALLY BY: JANICE SYLVESTRE - HL - 6/2001
C
C MR 1954 - 09/2004 FLDWAV Multi-Scenario Enhancement
C determine which data should be written for each scenario - make sure
C the files are actually written
C
CC CHARACTER FILIN*12,ATIM*6
CHARACTER*6 ATIM
CHARACTER*4 STONAM
CHARACTER*8 TSID
CHARACTER*20 FILNAM
CHARACTER*20 FILETYPE,FILEACCS,FILESTAT,FILEFORM_F,FILEFORM_U
CHARACTER*100 ENVVAR1,ENVVAR2
CHARACTER*150 FILNM
CHARACTER*150 FILANIM,DIRNAME,PATHNAME,UNIXCMD
COMMON/IONUM/IN,IPR,IPU
COMMON/M155/NU,JN,JJ,KIT,G,DT,TT,TIMF,F1
COMMON/SS55/NCS,A,B,DB,R,DR,AT,BT,P,DP,ZH
COMMON/LEV55/NLEV,DHLV,NPOND,DTHLV,IDTHLV
cc COMMON/FLDMAP55/NMAP,FILANIM,FILNAM,MPTIM
INCLUDE 'common/fdbug'
INCLUDE 'common/fcsegn'
INCLUDE 'common/ofs55'
INCLUDE 'common/opfil55'
INCLUDE 'common/fldmap55'
DIMENSION PO(1),NB(K1),XXLAT(K2,K1),XXLON(K2,K1),Y(K2,K1)
DIMENSION X(K2,K1),HS(K9,K2,K1),HLV(K22),NJFM(K22),NIFM(K22)
DIMENSION NJTO(K22),NITO(K22),NQL(K1),LQ1(K10,K1),LQN(K10,K1)
DIMENSION MPRV(K30),MPLOC(2,K30),JCK(K1),IMAP(K2,K1,K30),MRV(K1)
DIMENSION NJUN(K1),NSTR(K1),NST(K14,K1),BS(K9,K2,K1),GZO(K14,K1)
DIMENSION BSS(K9,K2,K1),STONAM(3,K27),DTMAP(K30)
C
C ================================= RCS keyword statements ==========
CHARACTER*68 RCSKW1,RCSKW2
DATA RCSKW1,RCSKW2 / '
.$Source: /fs/hseb/ob72/rfc/ofs/src/fcst_fldwav/RCS/wrtmap55.f,v $
. $', '
.$Id: wrtmap55.f,v 1.2 2004/09/24 20:52:53 jgofus Exp $
. $' /
C ===================================================================
C
IF(DTMAP(1).LT.1.0.AND.MPFRST.EQ.1) GO TO 400
TOL=0.0000001
c.... initialize imap parameter
DO 250 M=1,NMAP
DO 210 J=1,JN
N=NB(J)
DO 205 I=1,N
IMAP(I,J,M)=0
205 CONTINUE
210 CONTINUE
250 CONTINUE
c.... determine which reaches are used in each scenario
DO 15 M=1,NMAP
DO 1 J=1,JN
jck(j)=0
1 CONTINUE
DO 2 J=1,JN
IF(MPRV(M).EQ.J) GO TO 4
2 CONTINUE
c.... find the main river reach (jrv is the 1st river in scenario)
4 I1=MPLOC(1,M)
I2=MPLOC(2,M)
JRV=1
DO 6 I=I1,I2
IMAP(I,J,M)=JRV
6 CONTINUE
LRV=1
JCK(1)=J
c.... find the first order trib in the reach (jct is the junction)
IF(JN.EQ.1) GO TO 18
JRV=JRV+1
DO 8 J2=1,JN
JCT=MRV(J2)
IF(JCT.EQ.J.AND.NJUN(J2).GE.I1.AND.NJUN(J2).LE.I2) GO TO 10
8 CONTINUE
GO TO 15
10 N=NB(J2)
cc DO 12 I=1,N
cc IMAP(I,J2,M)=JRV
cc 12 CONTINUE
cc JCK(2)=J2
cc JRV=JRV+1
CALL MPSET55(JCT,JRV,JN,MRV,JCK,IMAP,NB,M,NJUN,I1,I2,K1,K2,K30)
c.... find all other associated tribs
IF(JN.LE.2) GO TO 18
DO 14 J3=2,JN
JCT=JCK(J3)
IF(JCT.GT.0) THEN
I1=1
I2=NB(JCT)
CALL MPSET55(JCT,JRV,JN,MRV,JCK,IMAP,NB,M,
. NJUN,I1,I2,K1,K2,K30)
ENDIF
14 CONTINUE
15 CONTINUE
18 IF(MPFRST.EQ.2) WRITE(JFSCEN,480) NMAP
CC DO 25 M=1,NMAP
DO 23 J=1,JN
N=NB(J)
DO 20 I=1,N
ISKIP=1
DO 19 M=1,NMAP
IF(IMAP(I,J,M).GT.0) ISKIP=0
19 CONTINUE
cc WRITE(JFSCEN,490) X(I,J),(IMAP(I,J,M), M=1,NMAP)
cc WRITE(JFXY,500) X(I,J),XXLAT(I,J),XXLON(I,J),HS(1,I,J)
IF(ISKIP.EQ.0.AND.MPFRST.EQ.2) THEN
WRITE(JFSCEN,490) X(I,J),(IMAP(I,J,M),M=1,NMAP)
WRITE(JFXY,510) X(I,J),XXLAT(I,J),XXLON(I,J),HS(1,I,J)
ENDIF
20 CONTINUE
23 CONTINUE
CC 25 CONTINUE
c.... write the forecast file
24 IF(MPFRST.EQ.2) WRITE(JFPRF,470)
IF(MPFRST.LT.2.AND.IOPNMAP.NE.1.AND.DTMAP(1).GE.1.0) THEN
c.... determine the files to be stored for animation
TIM=TT-DTH
cc IF(TIM.LT.0.) TIM=0.
DTANIM=(TIM)/DTMAP(1)
LANIM=DTANIM
MTIM=MPTIM*LANIM
DIFF=TIM-FLOAT(MTIM)
IF(ABS(DIFF).GT.TOL) GO TO 200
CALL TOCHAR55(MTIM,ATIM,ICOL)
LFILANIM=LENSTR(FILANIM)
PATHNAME=FILANIM(1:LFILANIM)//'AN'//ATIM//'.fcs'
FILNM=FILNAM(1:LENSTR(FILNAM))//'AN'//ATIM
cc K=INDEX(FILNM,'.')
cc IF(K.NE.0) LN=K-1
FILETYPE='FLDWAV-FLDVIEW '
FILEACCS='SEQUENTIAL'
FILESTAT='UNKNOWN'
FILEFORM_F='FORMATTED'
FILEFORM_U='UNFORMATTED'
LRECL=0
C
cc CALL OPFILE (PATHNAME,FILETYPE,FILEACCS,FILESTAT,FILEFORM_F,
cc * LRECL,JFANIM,IERR)
cc IF (IERR.NE.0) CALL OPNERR55 (PATHNAME,IOPNERR)
cc IF(MTIM.GT.0) THEN
CLOSE(JFANIM)
OPEN(JFANIM,FILE=PATHNAME)
cc ENDIF
cc WRITE(JFANIM,'(A)') PATHNAME(1:LENSTR(PATHNAME))
WRITE(JFANIM,'(A)') FILNM(1:LENSTR(FILNM))
ENDIF
LS=1
IF(MPFRST.EQ.2) WRITE(JFXSEC,480) NCS
cc WRITE(JFPRF,470)
DO 100 J=1,JN
CC IF(KMAP(J).EQ.1) THEN
N=NB(J)
DO 50 I=1,N
c.... check to see if cross section I is to be mapped
ISKIP=1
DO 25 M=1,NMAP
IF(IMAP(I,J,M).GT.0) ISKIP=0
25 CONTINUE
IF(ISKIP.EQ.1) THEN
DO 32 L=1,NSTR(J)
IF(NST(L,J).EQ.I) THEN
LS=LS+1
GO TO 50
ENDIF
32 CONTINUE
GO TO 50
ENDIF
CALL SECT55(PO(LCPR),PO(LOAS),BS,HS,PO(LOASS),
. BSS,J,I,Y(I,J),PO(LCHCAV),PO(LCIFCV),K1,K2,K9)
c.... find max elev on levee side
HLEV=-999.
DO 28 L=1,NLEV
IF(NJFM(L).EQ.J.AND.NIFM(L).EQ.I) THEN
HLEV=HLV(L)
DO 26 L2=1,NLEV
IF(NJTO(L2).EQ.NJTO(L).AND.NITO(L2).EQ.NITO(L).AND.
. HLV(L2).GT.HLEV) HLEV=HLV(L2)
26 CONTINUE
IF(HLEV.LT.HS(1,I,J)) HLEV=-999.
GO TO 40
ENDIF
28 CONTINUE
c.... triple the width at the lateral flow reach
NQ=NQL(J)
IF(NQ.GT.0) THEN
DO 35 L=1,NQ
L1=LQ1(L,J)
LN=LQN(L,J)
DO 30 LL=L1,LN
IF(I.EQ.LL) THEN
BT=BT*3
GO TO 40
ENDIF
30 CONTINUE
35 CONTINUE
ENDIF
c.... write the forecast file
40 IF(MPFRST.EQ.2) WRITE(JFPRF,500) X(I,J),Y(I,J),BT,HLEV
IF(MPFRST.LT.2.AND.IOPNMAP.NE.1.AND.DTMAP(1).GT.0.)
. WRITE(JFANIM,500) X(I,J),Y(I,J),BT,HLEV
IF(MPFRST.EQ.2) THEN
TSID='NONE'
DO 45 L=1,NSTR(J)
IF(NST(L,J).EQ.I) THEN
TSID=STONAM(1,LS)//STONAM(2,LS)
LS=LS+1
GO TO 47
ENDIF
45 CONTINUE
47 WRITE(JFXSEC,520) X(I,J),GZO(I,J),TSID,(BS(K,I,J)+
. BSS(K,I,J),K=1,NCS),(HS(K,I,J), K=1,NCS)
ENDIF
50 CONTINUE
CC ENDIF
100 CONTINUE
C CLOSE FILES
200 IF(MPFRST.EQ.2) THEN
IUNIT=0
CALL CLFILE ('FLDWAV-FLDVIEW',IUNIT,IERR)
cc CLOSE(JFXY)
cc CLOSE(JFPRF)
ELSE
CLOSE(JFANIM)
MPFRST=1
ENDIF
CC CLOSE(50)
CC CLOSE(51)
470 FORMAT('Peak')
480 FORMAT(I5)
490 FORMAT(F14.4,',',20(I5,','),$)
500 FORMAT(F15.4,',',F15.4,',',F15.4,',',F15.4)
510 FORMAT(20(F15.4,','),F15.4,',',F15.4,',',F15.4,',',F15.4)
520 FORMAT(F10.4,F10.2,2X,A8,100F10.2)
400 RETURN
END
|
C @(#)comdrp.f 20.3 2/13/96
subroutine comdrp (annote, iter, num1, deldrp, num2, delpku,
1 status, getpqv, numitr)
C This subroutine computes the generation reallocation.
C
C Parameters: ANNOTE = Character string identifying calls.
C ITER = Current solution iteration number.
C NUM1 = Count of busses which dropped generation
C this iteration.
C (Input) DELDRP = MW value of unallocated generation
C which must be dropped.
C (Output) DELDRP = MW value of unallocated generation
C remaining to be dropped.
C NUM2 = Count of busses which picked up generation
C this iteration.
C DELPKU = MW value of generation picked up this
C iteration.
C STATUS = 0/1 = no errors/errors encountered.
C
C GETPQV = Subroutine name for computing P, Q, V.
C
C NUMITR = Cumulative iteration count.
C
include 'ipfinc/parametr.inc'
include 'ipfinc/alpha.inc'
include 'ipfinc/alpha2.inc'
include 'ipfinc/blank.inc'
include 'ipfinc/bus.inc'
include 'ipfinc/comdrx.inc'
include 'ipfinc/ecvar.inc'
include 'ipfinc/gendrp.inc'
include 'ipfinc/intbus.inc'
include 'ipfinc/lfiles.inc'
include 'ipfinc/prt.inc'
c
c***kln Single to double precision.
c
double precision pgen, pnew, pmax, pmin, pnewmw, dropmw
double precision totpku, pmaxmw, pminmw, poldmw, totdrp
double precision delpct, pgenmw, pickup
integer status
character btyp * 1, commnt * 37, annote * (*)
external getpqv
num1 = 0
num2 = 0
if (idswb .ne. 0) then
call forbtm
write (outbuf,10) annote, iter
10 format (t10, a, i3, ' Status of machines with ',
& 'generation dropped or picked up ')
call shdlod(1)
write (outbuf,20)
20 format('0 Generator', t19, 'Type', t25, 'Zone',
1 t31, ' ----------------- Generation -----------------',
2 t95,'Comments')
call shdlod(2)
write (outbuf,30)
30 format(t34,'Minimum Maximum Initial Final Change')
call shdlod(3)
write (outbuf,40)
40 format(t34,' (MW) (MW) (MW) (MW) (MW)')
call shdlod(4)
outbuf = ' '
call shdlod(5)
call fortop
write (outbuf, 50) drptot, 'Initially dropped generation'
50 format (t71, f10.1, t95, a)
call prtout (1)
endif
itrtot = itrtot + 1
numitr = itrtot
status = 0
C Compute the total generation to be dropped. The varying nature
C of system and area slack busses require recomputation of this
C quantity.
C TOTDRP = total generation dropped in this case.
C DELDRP = generation dropped (deficit) this iteration.
if (oldrop .eq. -9.0e10) then
oldrop = -drptot
endif
totdrp = oldrop
deldrp = 0.0
do 110 i = 1, numdrp
nb = gndpno(i)
kt = inp2opt(nb)
pmaxmw = gndpmx(i)
pminmw = gndpmn(i)
pmin = pminmw / bmva
pmax = pmaxmw / bmva
if (annote .eq. 'DC Iteration') then
if (gndpty(i) .ne. 0 .and. numitr .gt. 1) then
C Update P- and Q-injections for area slack buses.
call getpqv (kt,pk,dpk,qk,dqk,vk)
pnetu(kt) = pk
endif
pgen = pnetu(kt) + ploadu(kt)
else
if (gndpty(i) .ne. 0) then
C Update P- and Q-injections for area slack buses.
call getpqv (kt,pk,dpk,qk,dqk,vk)
pnetu(kt) = pk
endif
pgen = pnetu(kt) + ploadu(kt)
pnew = pgen - ddim (pgen, pmax) + ddim (pmin, pgen)
pnetu(kt) = pnew - ploadu(kt)
endif
pnew = pgen - ddim (pgen, pmax) + ddim (pmin, pgen)
pnetu(kt) = pnew - ploadu(kt)
pnewmw = pnew * bmva
pgenmw = pgen * bmva
dropmw = pnewmw - pgenmw
totdrp = totdrp + dropmw
deldrp = deldrp + dropmw
C
C Update PGEN quantities on BUSDTA for non-slack busses.
C
if (gndpty(i) .eq. 0) then
busdta(8,nb) = busdta(8,nb) + dropmw
endif
if (dropmw .lt. -0.5) then
num1 = num1 + 1
commnt = 'Generation dropped'
else
commnt = ' '
endif
if (idswb .ne. 0) then
call typno (btyp, ntypu(kt))
write (outbuf, 100) bus(nb), base(nb), btyp, zone(nb),
1 pminmw, pmaxmw, pgenmw, pnewmw, dropmw, commnt
100 format (t3, a8, f6.1, t21, a1, t27, a2, t31, 5f10.1,
1 t95, a)
if (gndpty(i) .ne. 0) outbuf(122:) = '(Slack bus)'
call prtout (1)
endif
110 continue
if (itrtot .eq. 1) then
target = totdrp
else
target = deldrp
endif
delpku = 0.0
C
C "TARGET" is the additional generation pickup desired for this
C subroutine call.
C
do 170 itx = 1, 10
C
C First pass: determine the number and amount of eligible
C generators for pickup (NUM2, TOTPMX).
C
num2 = 0
spinpu = 0.0
totpmx = 0.0
C
C NUM2 = total number of eligible pickup generators
C (P_i < P_i_max)
C
C SPINPU = total spinning reserve (p.u.).
C TOTPMX = total P_max on eligible pickup generators.
C
do 130 i = 1, numgen
nb = gennum(i)
kt = inp2opt(nb)
pmax = busdta(7,nb) / bmva
C Update P- and Q-injections for area slack buses.
if (gentyp(i) .ne. 0) then
C Update P- and Q-injections for area slack buses.
call getpqv (kt,pk,dpk,qk,dqk,vk)
pnetu(kt) = pk
endif
pgen = pnetu(kt) + ploadu(kt)
if (itx .eq. 1) then
pold(i) = pgen
C Compensate DELPKU for slack bus excursions since
C previous iteration.
if (gentyp(i) .ne. 0) then
j = gentyp(i)
if (itrtot .eq. 1) slkgen(j) = genpol(i) / bmva
delpku = delpku + (pgen - slkgen(j)) * bmva
slkgen(j) = pgen
endif
endif
if (pgen + 0.005 .lt. pmax .and.
1 pmax .gt. 0.0 .and.
2 gentyp(i) .eq. 0) then
spinpu = spinpu + ddim (pmax, pgen)
totpmx = totpmx + pmax
num2 = num2 + 1
endif
130 continue
C
C Compute percentage pickup PCTPKU to balance DELDRP with
C TARGET. Note: TARGET <= 0 means pickup is => 0.
C
if (totpmx .eq. 0) then
delpct = 0.0
go to 172
else
delpct = (-delpku - target) / bmva / totpmx
endif
pctpku = pctpku + delpct
C
C Now apply this percentage pickup PCTPKU until TARGET is
C reached.
C
totpku = 0.0
do 160 i = 1, numgen
nb = gennum(i)
kt = inp2opt(nb)
pmax = busdta(7,nb) / bmva
pgen = pnetu(kt) + ploadu(kt)
pnew = dmin1 (genpol(i)/bmva + pctpku * pmax, pmax)
C Update PGEN quantities on BUSDTA for non-slack busses.
if (gentyp(i) .eq. 0) then
busdta(8,nb) = busdta(8,nb) + (pnew - pgen) * bmva
pnetu(kt) = pnew - ploadu(kt)
pnetu(kt) = pnew - ploadu(kt)
totpku = totpku + pnew * bmva - genpol(i)
delpku = delpku + (pnew - pgen) * bmva
endif
160 continue
if (gensum_flag .eq. 1) then
if (itx .eq. 1) call space (1)
write (outbuf, 162) itx, num1, target, num2, delpku,
1 totpmx * bmva, pctpku * 100.0
162 format (' Iteration ',i3, ' Total dropped ', i3, ' (',
1 f10.1, ') Total pickup ', i3, ' (', f10.1, ') P_max (',
2 f10.1, ') Pickup (', f8.2, ') % ')
call prtout (1)
endif
C
C Allocate PCTPKU until DELDRP < DRPTOL
C
if (abs(delpku + target) .le. drptol) go to 176
170 continue
172 write (errbuf(1), 174 ) 10, spinpu * bmva, target, delpku
174 format('Insufficent spinning reserve after ',i2,
1 ' iterations (',f10.1,'), amount dropped (', f10.1,
2 ') amount pickup (',f10.1,')')
call prterx ('W', 1)
status = 1
176 continue
C
C Summarize new allocated generation.
C
totpku = 0.0
delpku = 0.0
num2 = 0
do 230 i = 1, numgen
nb = gennum(i)
kt = inp2opt(nb)
pmaxmw = busdta(7,nb)
pminmw = 0.0
pgen = pnetu(kt) + ploadu(kt)
poldmw = genpol(i)
pgenmw = pgen * bmva
pickup = pgenmw - poldmw
totpku = totpku + pickup
j = gentyp(i)
if (j .gt. 0) then
delpku = delpku + pgenmw - slkgen(j) * bmva
else
delpku = delpku + pgenmw - pold(i) * bmva
endif
if (pgenmw - 0.5 .gt. poldmw) then
num2 = num2 + 1
endif
if (idswb .ne. 0) then
call typno (btyp, ntypu(kt))
if (pmaxmw .gt. 0.0) then
pct = 100.0 * pickup / pmaxmw
else
pct = 0.0
endif
write (outbuf, 220) bus(nb), base(nb), btyp, zone(nb),
1 pminmw, pmaxmw, poldmw, pgenmw, pickup, pct
220 format (t3, a8, f6.1, t21, a1, t27, a2, t31, 5f10.1,
1 t95, 'Generation Pickup ',f6.2, ' %')
if (gentyp(i) .ne. 0) outbuf(122:) = '(Slack bus)'
call prtout (1)
endif
230 continue
oldrop = totdrp + totpku
if (idswb .ne. 0) then
write (outbuf, 240) totdrp
240 format ('0 Total dropped', t71, f10.1)
call prtout (1)
write (outbuf, 242) totpku
242 format (' Total pickup', t71, f10.1)
call prtout (1)
endif
call space (1)
do 260 i = 1, 5
outbuf = ' '
call shdlod(i)
260 continue
return
end
|
SUBROUTINE RADIAL
INCLUDE 'SOLDIV.FI'
C CALCULATES RADIAL LOSS TERMS FOR SOLDIV PLASMA
C RADIAL LOSS RATES USING BOHM DIFFUSION
IF(CHIRSOL.EQ.0.0) GOTO 50
C PARTICLE
TAUPART = (DELN**2)/CHIRSOL
DNRAD = (DELN/TAUPART)*(XLPERP*XNSOL +
2 (XLPAR - XLPERP - DELLT)*XNDIV/EPDIV + DELLT*XND/EPDIV)
C ENERGY
TAUENERGY = (DELEA**2)/CHIRSOL
DQPERP = (5.*DELEA/TAUPART)*XK*(XNSOL*TSOL*XLPERP +
2 (XLPAR - XLPERP - DELLT)*XNDIV*TDIV/EPDIV +
3 DELLT*XND*TD/EPDIV)
TRADLOSS = (XNSOL*TSOL*XLPERP +
2 (XLPAR - XLPERP - DELLT)*XNDIV*TDIV/EPDIV +
3 DELLT*XND*TD/EPDIV)/(XNSOL*XLPERP +
2 (XLPAR - XLPERP - DELLT)*XNDIV/EPDIV +
3 DELLT*XND/EPDIV)
DQPERP = 3.*XK*TRADLOSS*DNRAD
GOTO 100
50 DQPERP = FOUT*((YIONSOL+YIONSOLXPT)*TSEP+YIONDIV*TDIV)*XK
DNRAD = 0.
100 RETURN
END |
* vert_lpd1.F
* this file is part of the process {MNE1, MNE1} -> {0, 0}
* generated by WriteSquaredME 5 Oct 2009 6:36
subroutine vert_lpd1
implicit character (a-s,u-z)
implicit double complex (t)
#include "vars.h"
tmp7 = -(1/2.D0*(AAABR(1365)*MTR144(1,1))) +
- 1/2.D0*(AAABR(1365)*MTR145(1,1)) +
- AAABR(1995)*MTR144(1,1) - AAABR(1995)*MTR145(1,1)
tmp8 = 1/2.D0*(AAABR(1365)*MTR144(1,1)) -
- 1/2.D0*(AAABR(1365)*MTR145(1,1)) -
- AAABR(1995)*MTR144(1,1) + AAABR(1995)*MTR145(1,1)
Cloop(1) = Cloop(1) +
- (Cval(cc0,iint3(lpd1))*
- (-(1/(8.D0*Pi**2)*
- (AbbSum25*AAABR(8091)*lpdMass(lpd1)*MTR077(lpd1)*
- MTR132(1,1))) +
- 1/(8.D0*Pi**2)*
- (AbbSum24*AAABR(8091)*lpdMass(lpd1)*MTR077(lpd1)*
- MTR133(1,1))))/(-MH3sq + S) +
- (Cval(cc0,iint3(lpd1))*
- (-(1/(8.D0*Pi**2)*
- (AbbSum25*AAABR(8091)*lpdMass(lpd1)*MTR078(lpd1)*
- MTR134(1,1))) +
- 1/(8.D0*Pi**2)*
- (AbbSum24*AAABR(8091)*lpdMass(lpd1)*MTR078(lpd1)*
- MTR135(1,1))))/(-MZ2 + S) +
- (Cval(cc00,iint3(lpd1))*
- (1/(4.D0*Pi**2)*(AbbSum4*MNE1*tmp7*AAABR(8091)) +
- 1/(4.D0*Pi**2)*
- (AbbSum21*AAABR(8091)*
- (AAABR(1995) - 1/2.D0*AAABR(1365))*MTR144(1,1)) +
- 1/(4.D0*Pi**2)*
- (AbbSum20*AAABR(8091)*
- (AAABR(1995) - 1/2.D0*AAABR(1365))*MTR145(1,1))) +
- cint24(lpd1)*(1/(8.D0*Pi**2)*
- (AbbSum4*MNE1*tmp8*AAABR(8091)) +
- 1/(8.D0*Pi**2)*
- (AbbSum23*AAABR(8091)*
- (AAABR(1995) - 1/2.D0*AAABR(1365))*MTR144(1,1)) +
- 1/(8.D0*Pi**2)*
- (AbbSum22*AAABR(8091)*
- (AAABR(1995) - 1/2.D0*AAABR(1365))*MTR145(1,1))) +
- cint23(lpd1)*(1/(8.D0*Pi**2)*
- (AbbSum4*MNE1*tmp8*AAABR(8091)) +
- 1/(4.D0*Pi**2)*
- (AbbSum11*AAABR(8091)*
- (-AAABR(1995) + 1/2.D0*AAABR(1365))*MTR144(1,1)) +
- 1/(4.D0*Pi**2)*
- (AbbSum7*AAABR(8091)*
- (-AAABR(1995) + 1/2.D0*AAABR(1365))*MTR145(1,1)))+
- Cval(cc12,iint3(lpd1))*
- (1/(4.D0*Pi**2)*(AbbSum19*MNE1*tmp7*AAABR(8091)) +
- 1/(8.D0*Pi**2)*
- ((4*AbbSum18 + AbbSum17*(T - U))*AAABR(8091)*
- (-AAABR(1995) + 1/2.D0*AAABR(1365))*MTR144(1,1)) +
- 1/(8.D0*Pi**2)*
- ((4*AbbSum16 + AbbSum15*(T - U))*AAABR(8091)*
- (-AAABR(1995) + 1/2.D0*AAABR(1365))*MTR145(1,1)))+
- Cval(cc2,iint3(lpd1))*
- (1/(8.D0*Pi**2)*
- (AbbSum4*MNE1*MNE1sq*tmp7*AAABR(8091)) +
- 1/(8.D0*Pi**2)*
- (AbbSum14*AAABR(8091)*
- (AAABR(1995) - 1/2.D0*AAABR(1365))*MTR144(1,1)) +
- 1/(4.D0*Pi**2)*
- (AbbSum11*MNE1sq*AAABR(8091)*
- (AAABR(1995) - 1/2.D0*AAABR(1365))*MTR144(1,1)) +
- 1/(16.D0*Pi**2)*
- (MNE1*(-2*AbbSum5 + AbbSum4*(2*MNE1sq - S))*
- AAABR(8091)*(-AAABR(1995) + 1/2.D0*AAABR(1365))*
- MTR144(1,1)) +
- 1/(8.D0*Pi**2)*
- (AbbSum13*T*AAABR(8091)*
- (-AAABR(1995) + 1/2.D0*AAABR(1365))*MTR144(1,1)) +
- 1/(8.D0*Pi**2)*
- (AbbSum12*U*AAABR(8091)*
- (-AAABR(1995) + 1/2.D0*AAABR(1365))*MTR144(1,1)) +
- 1/(8.D0*Pi**2)*
- (AbbSum10*AAABR(8091)*
- (AAABR(1995) - 1/2.D0*AAABR(1365))*MTR145(1,1)) +
- 1/(4.D0*Pi**2)*
- (AbbSum7*MNE1sq*AAABR(8091)*
- (AAABR(1995) - 1/2.D0*AAABR(1365))*MTR145(1,1)) +
- 1/(16.D0*Pi**2)*
- (MNE1*(-2*AbbSum6 + AbbSum4*(2*MNE1sq - S))*
- AAABR(8091)*(AAABR(1995) - 1/2.D0*AAABR(1365))*
- MTR145(1,1)) +
- 1/(8.D0*Pi**2)*
- (AbbSum9*T*AAABR(8091)*
- (-AAABR(1995) + 1/2.D0*AAABR(1365))*MTR145(1,1)) +
- 1/(8.D0*Pi**2)*
- (AbbSum8*U*AAABR(8091)*
- (-AAABR(1995) + 1/2.D0*AAABR(1365))*MTR145(1,1))))/
- (-MZ2 + S)
end
|
SUBROUTINE NULLCOUNT32(A,N,NNULL)
IMPLICIT NONE
C
C_TITLE NULLCOUNT32 - Count 'null' flags in a REAL*4 array
C
C_ARGS TYPE VARIABLE I/O DESCRIPTION
INTEGER*4 N !I # of elements in A
REAL*4 A(N) !I Array to be searched
INTEGER*4 NNULL !O # of nulls found
C
C_DESC Counts the number of nulls in a REAL*4 array, where a null is
C defined as "all bits on," the most negative value.
C
C_HIST 11-Aug-89 Randolph Kirk U.S.G.S. Flagstaff Original Version
C
C_END
#include "clinom_specpix.inc"
INTEGER*4 I ! Loop counter
NNULL=0
DO I=1,N
C IF (A(I).EQ.'FFFFFFFF'X) NNULL=NNULL+1
IF (A(I).LT.VALID_MIN4.OR.A(I).GT.VALID_MAX4) NNULL=NNULL+1
ENDDO
RETURN
END
|
block data inialpha
double precision alpha(4)
common /healpha/ alpha
data alpha / 0.297104,
* 1.236745,
* 5.749982,
* 38.216677/
end
subroutine basis(x,chi)
*
* returns the basis function chi(i)=exp(-alpha(i)*x^2)
*
double precision x,chi(4),alpha(4)
common /healpha/ alpha
do i=1,4
chi(i)=dexp(-alpha(i)*x*x)
enddo
return
end
subroutine hes(S)
*
* Returns the S matrix
*
parameter (pi=3.141592653589793d0)
double precision S(4,4),alpha(4)
common /healpha/ alpha
do i=1,4
do j=1,4
S(i,j) = (pi/(alpha(i)+alpha(j)))**1.5d0
enddo
enddo
return
end
subroutine heh(H)
*
* Returns the H matrix
*
parameter (pi=3.141592653589793d0)
double precision H(4,4),alpha(4)
common /healpha/ alpha
do i=1,4
do j=1,4
H(i,j)=
* 3.0d0*alpha(i)*alpha(j)*pi**1.5d0/(alpha(i)+alpha(j))**2.5d0
* +4.d0*pi/(alpha(i)+alpha(j))
enddo
enddo
return
end
subroutine heq(Q)
*
* Returns the Q hypermatrix
*
parameter (pi=3.141592653589793d0)
double precision Q(4,4,4,4),alpha(4),a,b,p
common /healpha/ alpha
p=2.d0*pi**2.5d0
do i1=1,4
do i2=1,4
do i3=1,4
do i4=1,4
a=alpha(i1)+alpha(i3)
b=alpha(i2)+alpha(i4)
Q(i1,i2,i3,i4) = p/(a*b*dsqrt(a+b))
enddo
enddo
enddo
enddo
return
end
subroutine hef(H,Q,C,F)
*
* Calculate the F matrix
*
* 'H' -- input; matrix
* 'Q' -- input; hypermatrix
* 'C' -- iput; vector
* 'F' -- output; matrix
double precision H(4,4),Q(4,4,4,4),C(4),F(4,4)
do i=1,4
do j=1,4
F(i,j)=H(i,j)
do k1=1,4
do k2=1,4
F(i,j)=F(i,j)+Q(i,k1,j,k2)*C(k1)*C(k2)
enddo
enddo
enddo
enddo
return
end
subroutine heEG(H,Q,C,EG)
*
* Calculate Ground energy
*
* 'H' -- input; matrix
* 'Q' -- input; hypermatrix
* 'C' -- input; vector
* 'EG' -- output; Ground Energy
*
double precision H(4,4),Q(4,4,4,4),C(4),EG,a
EG=0.d0
do i=1,4
do j=1,4
a=2.d0*H(i,j)
do k1=1,4
do k2=1,4
a=a+Q(i,k1,j,k2)*C(k1)*C(k2)
enddo
enddo
EG=EG+a*C(i)*C(j)
enddo
enddo
return
end
subroutine normC(S,C)
*
* Normalises the C vector using the S matrix:
* \sum_{p,q} C_{p} S_{pq} C_{q} = 1
*
* 'S' -- input; the S matrix
* 'C' -- input output; The vector to be normalised C
*
double precision S(4,4), C(4), a
a=0.d0
do i=1,4
do j=1,4
a=a+S(i,j)*C(i)*C(j)
enddo
enddo
a=dsqrt(a)
do i=1,4
C(i)=C(i)/a
enddo
return
end
|
module probe_def_m
implicit none
type probe_t
real*8 :: mass, momentum(3), energy
end type probe_t
integer, parameter :: nprobe = 1
&, iprobe_domain = 1
end module probe_def_m
c
module probe_m
c
c----------------------------------------
c aims to monitor the conservation laws over
c the entire domain and print out the values
c----------------------------------------
use probe_def_m
use global_const_m
use number_def_m
use workfc_m
use block_m
use e3_func_m
use local_m
implicit none
c
type(probe_t) :: probe(nprobe)
c
contains
c
subroutine probe_conservation(y,x,shp_table,shgl_table)
real*8, intent(in) :: y(nshg,ndof), x(numnp,nsd)
real*8, intent(in) :: shp_table(MAXTOP,maxsh,MAXQPT), shgl_table(MAXTOP,nsd,maxsh,MAXQPT)
integer :: iblk
integer :: sgn(npro,nshl)
real*8, pointer :: s(:,:)
c
call init_probe(probe(1))
c
set_block_ptr => set_interior_block
do iblk = 1,nelblk
c
call set_interior_block(iblk)
call set_block_ptr(iblk)
c
call e3_malloc_ptr
allocate(yl(npro,nshl,ndof),xl(npro,nenl,nsd))
allocate(s(npro,nflow))
c
if (ipord .gt. 1) then
call getsgn(ien,sgn)
endif
c
call localy(y,yl,ien,ndofl,'gather ',nshg,nshl,npro,ipord)
call localx(x,xl,ien,nsd,'gather ',nshg,nshl,npro)
call e3_int_conserv(s,shp_table(lcsyst,1:nshl,:),shgl_table(lcsyst,1:nsd,1:nshl,:),sgn)
c
c...apply any material condtion here..
c
call set_probe(probe(1),s)
c
call e3_mfree_ptr
deallocate(yl,xl)
deallocate(s)
c
enddo
c
call get_probe_global
c
end subroutine probe_conservation
c
subroutine init_probe(this)
type(probe_t), intent(inout) :: this
this%mass = zero
this%momentum = zero
this%energy = zero
end subroutine init_probe
c
subroutine set_probe(this,dui)
type(probe_t), intent(inout) :: this
real*8, dimension(npro,nflow), intent(in) :: dui
this%mass = this%mass + sum(dui(:,1))
this%momentum(1) = this%momentum(1) + sum(dui(:,2))
this%momentum(2) = this%momentum(2) + sum(dui(:,3))
this%momentum(3) = this%momentum(3) + sum(dui(:,4))
this%energy = this%energy + sum(dui(:,5))
end subroutine set_probe
c
subroutine get_probe_global
use timdat_m
use mio_m
implicit none
include "mpif.h"
real*8, dimension(nprobe*nflow) :: myprobe,globalprobe
integer :: i, ierr
do i = 1,nprobe
myprobe(1+(i-1)*nflow) = probe(i)%mass
myprobe(2+(i-1)*nflow) = probe(i)%momentum(1)
myprobe(3+(i-1)*nflow) = probe(i)%momentum(2)
myprobe(4+(i-1)*nflow) = probe(i)%momentum(3)
myprobe(5+(i-1)*nflow) = probe(i)%energy
enddo
globalprobe = zero
call mpi_allreduce(myprobe,globalprobe,nprobe*nflow,MPI_DOUBLE_PRECISION,MPI_SUM, MPI_COMM_WORLD,ierr)
if (myrank == 0) then
write(*,200) lstep,globalprobe(1:5)
write(iconserv,100) lstep,globalprobe(1:5)
endif
100 format(1x,i6,5e24.16)
200 format(1p,'Conservation: ',i6,5(2x,e10.3))
end subroutine get_probe_global
c
end module probe_m
|
SUBROUTINE GETINT(ACRCY,ILBL,ILBM,IINTS)
C
C
C
IMPLICIT REAL*8 (A-H,O-Z)
C
CTJL EXTENDED DUMMY IINTS
C
INTEGER REFWLK,SYMORB,MAXB,LVFRM1,IINTS(1)
C
COMMON /TAPES/ ITAP52,ITAPE5,ITAPE6,ITAP58,ITAP12,ITAP99,ITAP04
*, ITAPE3,ITAP05,ITAP06
COMMON /DIMS/ NBF,NSYM,NORBS,NROWS,NROWS4,NWKS,NWKS2,NLEVS
*, NROWOC,NROW4O,NWKSOC,NLEVOC,NORBOC,LEVFRM
*, NWKSMX,NLWKMX,NUWKMX,MAXB,NROOTS,LVFRM1,NREFS
COMMON /INTS/ NMAX,NMAX2,NGROUP,NBLKOC,NUMIJ,SYMORB,INTSRT
COMMON /DIAG/ REP,FZCORE,EGUESS,ECI,REFWLK,MXITER,CNVERG,ICNVG
*, ITER,SQCDIF,NROOT
C
DIMENSION ILBL(20),ILBM(26)
C
CALL DCDLBL(ITAP52,ILBL,ILBM,NGRPS,NMAX,NSYM,ACRCY,FZCORE,REP)
CALL RGETSA(ITAP52,INTSRT)
WRITE(ITAPE6,14)ILBL
14 FORMAT(/,1H ,'LABEL FROM INTEGRALS : ',20A4,/)
WRITE(ITAPE6,15)NSYM
15 FORMAT(1H ,'THE NUMBER OF SYMMETRY TYPES =',I10)
WRITE(ITAPE6,16)NMAX
16 FORMAT(1H ,'THE INTEGRAL GROUP SIZE =',I10)
WRITE(ITAPE6,17)NGRPS
17 FORMAT(1H ,'THE NUMBER OF THESE GROUPS =',I10)
IF(NGROUP.NE.NGRPS) GO TO 900
WRITE(ITAPE6,18)
18 FORMAT(/)
WRITE(ITAPE6,19)FZCORE
WRITE(ITAPE6,20)REP
WRITE(ITAPE6,21)ACRCY
19 FORMAT(1H ,'FROZEN CORE ENERGY = ',F14.8)
20 FORMAT(1H ,'NUCLEAR REPULSION = ',F14.8)
21 FORMAT(1H ,'LOOP CUTOFF VALUE = ',E14.4,/)
C
C--------------------------------------------------------NXTBLK
C
ENTRY NXTBLK(ACRCY,ILBL,ILBM,IINTS)
C
CALL SREAD(ITAP52,IINTS,NMAX2)
RETURN
900 WRITE(ITAPE6,910) NGRPS,NGROUP
910 FORMAT(' IN GETINT GROUPS DO NOT MATCH NGRPS=',I6,' NGROUP=',I6)
CALL mabort
END
|
SUBROUTINE CUBHLX (START, ROTS, HUE, GAMMA, NLEVS, RED, GRN, BLU,
* NLO, nHI)
C-----------------------------------------------------------------------
C! OFM helix in color intensity space called by TVHELX
C# POPS=appl TV-appl
C-----------------------------------------------------------------------
C; Copyright (C) 2010
C; Associated Universities, Inc. Washington DC, USA.
C;
C; This program is free software; you can redistribute it and/or
C; modify it under the terms of the GNU General Public License as
C; published by the Free Software Foundation; either version 2 of
C; the License, or (at your option) any later version.
C;
C; This program is distributed in the hope that it will be useful,
C; but WITHOUT ANY WARRANTY; without even the implied warranty of
C; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
C; GNU General Public License for more details.
C;
C; You should have received a copy of the GNU General Public
C; License along with this program; if not, write to the Free
C; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
C; MA 02139, USA.
C;
C; Correspondence concerning AIPS should be addressed as follows:
C; Internet email: aipsmail@nrao.edu.
C; Postal address: AIPS Project Office
C; National Radio Astronomy Observatory
C; 520 Edgemont Road
C; Charlottesville, VA 22903-2475 USA
C-----------------------------------------------------------------------
C Does a helix in OFM colors, which is monotonically increasing in
C perceived intensity (since R, G, B are appropriately weighted).
C Calculates a "helix" colour table. The colours run along the
C diagonal of the [R,G,B] colour cube, from black [0,0,0] to white
C [1,1,1]. Deviations away from the diagonal vary quadratically,
C increasing from zero at black, to a maximum, then decreasing to
C zero at white, all the time rotating in colour (i.e. a tapered
C helix along the [R,G,B] diagonal).
C
C The parameters controlling the colour helix are:
C
C START colour (1=red, 2=green, 3=red; e.g. 0.5=purple);
C ROTS rotations in colour (typically -1.5 to 1.5, e.g. -1.0
C is one blue->green->red cycle);
C HUE for hue intensity scaling (in the range 0.0 (B+W) to
C 1.0 to be strictly correct, larger values may be OK
C with particular start/end colours);
C GAMMA set the gamma correction for intensity.
C
C The routine returns a colour table NLEVS elements long in RED,
C GRN and BLU (each element in the range 0.0 to 1.0), and also
C returns the number of values, NLO and NHI, that were clipped to
C 0.0 or 1.0 respectively.
C Dave Green --- MRAO --- 2010 September 20th
C-----------------------------------------------------------------------
REAL START, ROTS, HUE, GAMMA, RED(*), GRN(*), BLU(*)
INTEGER NLEVS, NLO, NHI
C
REAL PI, FRACT, ANGLE, AMP
INTEGER I
C-----------------------------------------------------------------------
PI = 4.0 * ATAN (1.0)
NLO = 0
NHI = 0
C
DO 20 I = 1,NLEVS
FRACT = FLOAT (I-1) / FLOAT (NLEVS-1)
ANGLE = 2 * PI * (START/3.0 + 1.0 + ROTS * FRACT)
FRACT = FRACT ** GAMMA
AMP = HUE * FRACT * (1-FRACT)/2.0
RED(I) = FRACT + AMP * (-0.14861 * COS(ANGLE) +
* 1.78277 * SIN(ANGLE))
GRN(I) = FRACT + AMP * (-0.29227 * COS(ANGLE) -
* 0.90649 * SIN(ANGLE))
BLU(I) = FRACT + AMP * (+1.97294 * COS(ANGLE))
IF (RED(I).LT.0.0) THEN
RED(I) = 0.0
NLO = NLO + 1
END IF
IF (GRN(I).LT.0.0) THEN
GRN(I) = 0.0
NLO = NLO + 1
END IF
IF (BLU(I).LT.0.0) THEN
BLU(I) = 0.0
NLO = NLO + 1
END IF
IF (RED(I).GT.1.0) THEN
RED(I) = 1.0
NHI = NHI + 1
END IF
IF (GRN(I).GT.1.0) THEN
GRN(I) = 1.0
NHI = NHI + 1
END IF
IF (BLU(I).GT.1.0) THEN
BLU(I) = 1.0
NHI = NHI + 1
END IF
20 CONTINUE
C
999 RETURN
END
|
SUBROUTINE EQMCKS
C
C THIS SUBROUTINE CALCULATES AND OUTPUTS OVERALL EQUILIBRIUM FORCES
C
C THE INPUT FILES ARE
C KSCC - CASE CONTROL - NOT PREPOSITIONED.
C KPGG - LOAD VECTORS - FILE 110 OR SCRATCH4
C KQG - SPC CONSTRAINTS - FILE 111 OR SCRATCH5
C QMG - MPC CONSTRAINTS - SCRATCH3
C DT - RIGID BODY TRANS - SCRATCH2
C
LOGICAL LSTEIG
INTEGER EJECT ,NAME(2) ,PARM ,
1 RDNRW ,RDRW ,WRTNRW ,WRTRW
REAL HEAD(2,4),COR1(8,1),COR3(8,3)
CHARACTER UFM*23,UWM*25
COMMON /XMSSG / UFM,UWM
COMMON /NAMES / RDNRW,RDRW,WRTNRW,WRTRW,KRW,KNRW,KNERW
CWKBR 3/94 SPR93007 COMMON /SYSTEM/ ISBZ,NOUT
COMMON /SYSTEM/ ISBZ,NOUT,DUM(52),IPREC
COMMON /BLANK / IOPT,IGPT,NSKIP,SKPB(15),CORE(8,4)
COMMON /UNPAKX/ IUNPR,IUNRW,NUNRW,IUNINC
COMMON /MPYADX/ MA(7),MB(7),MC(7),MD(7),MZ,MT,MSAB,MSC,MPR,MSCR
COMMON /EQMK1 / KSCC,KEQIN(8),KPGG,KQG,KCSTM,KLAMA,KOQM,KSCR(7)
1, KMPC,KLOAD,KSPC,PARM(4)
CZZ COMMON /ZZEQMS/ ZZ(1)
COMMON /ZZZZZZ/ ZZ(20000)
EQUIVALENCE (MB(6),FREQ), (CORE(1,1),COR1(1,1),COR3(1,1))
DATA NAME / 4HEQMC,4HKS /
DATA HEAD / 4HAPPL,4HIED , 4HSPCF,4HORCE, 4HMPCF,4HORCE
1, 4H---T,4HOTAL /
C
PARM(3) = NAME(1)
PARM(4) = NAME(2)
NZZ = KORSZ (ZZ)
NZZ3 = NZZ - 3*ISBZ + 1
NZZ2 = NZZ3 + ISBZ
NZZ1 = NZZ2 + ISBZ
C
NVEC = 0
MA(1) = KSCR(2)
MC(1) = 0
CALL RDTRL (MA)
MZ = NZZ
MT = 0
MSAB = 1
MSC = 1
CWKBR 11/93 SPR93007 MPR = 1
MPR = IPREC
MSCR = KSCR(1)
C
C CALCULATE DT*PG ON SCRATCH7
C
IF (KLOAD .LE. 0) GO TO 40
MB(1) = KPGG
MD(1) = KSCR(7)
CALL RDTRL (MB)
MD(3) = MA(3)
MD(4) = MB(4)
CWKBR 11/93 SPR93007 MD(5) = 1
MD(5) = IPREC
CALL MPYAD (ZZ,ZZ,ZZ)
IF (MD(3) .EQ. MD(2)) MD(4) = 1
CALL WRTTRL (MD)
NVEC = MD(2)
C
C CALCULATE DT*QG ON SCRATCH6
C
40 IF (KSPC .LE. 0) GO TO 50
MB(1) = KQG
MD(1) = KSCR(6)
CALL RDTRL (MB)
MD(3) = MA(3)
MD(4) = MB(4)
CWKBR 11/93 SPR93007 MD(5) = 1
MD(5) = IPREC
CALL MPYAD (ZZ,ZZ,ZZ)
IF (MD(3) .EQ. MD(2)) MD(4) = 1
CALL WRTTRL (MD)
NVEC = MAX0(NVEC,MD(2))
C
C CALCULATE DT*MPC ON SCRATCH5
C
50 IF (KMPC .LE. 0) GO TO 60
MD(1) = KSCR(5)
MB(1) = KSCR(3)
CALL RDTRL (MB)
PARM(2) = MB(1)
IF (MB(1) .LE. 0) GO TO 520
MD(3) = MA(3)
MD(4) = MB(4)
CWKBR 11/93 SPR93007 MD(5) = 1
MD(5) = IPREC
CALL MPYAD (ZZ,ZZ,ZZ)
IF (MD(3) .EQ. MD(2)) MD(4) = 1
CALL WRTTRL (MD)
NVEC = MAX0(MD(2),NVEC)
60 IF (NVEC .LE. 0) GO TO 400
C
C POSITION CASE CONTROL
C
CALL GOPEN (KSCC,ZZ(NZZ1),RDRW)
IF (NSKIP .GT. 0) GO TO 70
C
C RESERVE THIRD BUFFER FOR LAMA
C
IBFL = NZZ3
PARM(2) = KLAMA
CALL GOPEN (KLAMA,ZZ(NZZ3),RDRW)
CALL FWDREC (*510,KLAMA)
GO TO 90
70 IBFL = NZZ2
IF (NSKIP .LE. 1) GO TO 90
C
C ASSUME USER MAY MALADJUST NSKIP
C
J = NSKIP - 1
PARM(2) = KSCC
DO 80 I = 1,J
80 CALL FWDREC (*510,KSCC)
C
C READ INTO CORE AS MANY (MAXVEC) VECTORS THAT FIT
C
90 NENTRY = 0
IF (KLOAD .GT. 0) NENTRY = 6
IF (KMPC .GT. 0) NENTRY = NENTRY + 6
IF (KSPC .GT. 0) NENTRY = NENTRY + 6
C
MAXVEC = (IBFL-1)/NENTRY
IF (MAXVEC .GE. NVEC) GO TO 110
C
C INSUFFICIENT CORE TO DO ALL VECTORS
C
CALL PAGE2 (2)
WRITE (NOUT,100) UWM,MAXVEC,NAME
100 FORMAT (A25,' 2374, INSUFFICIENT CORE TO PROCESS MORE THAN',I7,
1 ' VECTORS IN ',2A4)
C
IF (MAXVEC .LE. 0) GO TO 400
C
110 MAXVEC = MIN0 (NVEC,MAXVEC)
L = 1
MA(1) = 0
IF (KLOAD .LE. 0) GO TO 160
PARM(2) = KSCR(7)
MA(1) = 1
ASSIGN 160 TO IRET
C
C INTERNAL FUNCTION TO LOAD MAXVEC COLUMNS INTO CORE
C
120 CONTINUE
CALL GOPEN (PARM(2),ZZ(NZZ2),RDRW)
IUNPR = 1
IUNINC = 1
IUNRW = 1
NUNRW = 6
C
DO 150 MT = 1,MAXVEC
CALL UNPACK (*130,PARM(2),ZZ(L))
GO TO 150
130 MPR = L - 1
DO 140 I = 1,6
MPR = MPR + 1
140 ZZ(MPR) = 0.0
150 L = L + 6
C
CALL CLOSE (PARM(2),KRW)
GO TO IRET, (160,170,180)
C
160 MA(2) = 0
IF (KSPC .LE. 0) GO TO 170
PARM(2) = KSCR(6)
MA(2) = L
ASSIGN 170 TO IRET
GO TO 120
C
170 MA(3) = 0
IF (KMPC .LE. 0) GO TO 180
PARM(2) = KSCR(5)
MA(3) = L
ASSIGN 180 TO IRET
GO TO 120
C
180 IVEC = 0
LSTEIG = .FALSE.
CALL PAGE1
C
C LOOP ON OUTPUT
C
200 CONTINUE
IVEC = IVEC + 1
IF (LSTEIG) GO TO 260
PARM(2) = KSCC
CALL READ (*250,*500,KSCC,MB(1),7,1,I)
I = MB(1)
IF (IVEC.EQ.1 .OR. EJECT(11).NE.0) WRITE (NOUT,210) IGPT
210 FORMAT (1H0,20X,'E Q U I L I B R I U M C H E C K L O A D S',
1 /,1H0,16X,'RESULTANT LOADS AT POINT',I7,
2 ' IN BASIC COORDINATE SYSTEM')
IF (NSKIP .LE. 0) GO TO 260
C
C STATICS SUBCASES
C
IF (MB(4) .EQ. 0) MB(4) = MB(7)
IF (MB(4) .EQ. 0) MB(4) = MB(6)
WRITE (NOUT,220) MB(1),MB(4)
220 FORMAT (1H0,24X,7HSUBCASE,I8,8H, LOAD,I8)
WRITE (NOUT,230)
230 FORMAT (1H0,5X,46H-TYPE- T1 T2 T3,
1 13X,32HR1 R2 R3)
C
240 FORMAT (5X,2A4,1P,6E15.6)
C
GO TO 300
C
C EOF FOUND
C
250 CONTINUE
IF (IVEC .GT. MAXVEC) GO TO 400
IF (NSKIP .GT. 0) GO TO 510
LSTEIG = .TRUE.
C
C EIGENVALUE PROBLEM
C
260 PARM(2) = KLAMA
CALL READ (*510,*500,KLAMA,MB(2),7,0,I)
WRITE (NOUT,270) MB(1),MB(2),FREQ
270 FORMAT (1H0,24X,7HSUBCASE,I8,8H, MODE,I5,13H, FREQUENCY,
1 1P,E15.6)
WRITE (NOUT,230)
C
C LOOP ON OUTPUT CATAGORY
C
300 K = NENTRY/6 + 1
IHDCNT = 1
DO 310 I = 3,8
310 CORE(I,K) = 0.0E0
C
DO 330 I = 1,3
IF (MA(I) .EQ. 0) GO TO 330
CORE(1,IHDCNT) = HEAD(1,I)
CORE(2,IHDCNT) = HEAD(2,I)
J = MA(I) + IVEC*6 - 6
C
DO 320 L = 3,8
CORE(L,IHDCNT) = ZZ(J)
CORE(L,K) = CORE(L,K) + ZZ(J)
J = J + 1
320 CONTINUE
IHDCNT = IHDCNT + 1
330 CONTINUE
C
CORE(1,K) = HEAD(1,4)
CORE(2,K) = HEAD(2,4)
IF (K .EQ. 2) WRITE (NOUT,240) COR1
IF (K .EQ. 3) WRITE (NOUT,240) COR3
IF (K .EQ. 4) WRITE (NOUT,240) CORE
IF (IVEC .LT. MAXVEC) GO TO 200
400 CALL CLOSE (KSCC,KRW)
IF (NSKIP .LE. 0) CALL CLOSE (KLAMA,KRW)
RETURN
C
C ERROR MESSAGES
C
C EOR
C
500 PARM(1) = 3
GO TO 600
C
C EOF
C
510 PARM(1) = 2
GO TO 600
C
C ILLEGAL INPUT
C
520 PARM(1) = 1
GO TO 600
C
600 CALL MESAGE (PARM(1),PARM(2),PARM(3))
GO TO 400
END
|
C
C NLP-UNCONSTRAINED-CLI/NELDER-MEAD/__ORIG/SRC/NELMIN.F
C =============================================================================
C NONLINEAR OPTIMIZATION ALGORITHMS MULTILANG. VERSION 0.1
C =============================================================================
C NONLINEAR PROGRAMMING ALGORITHMS AS THE (UN-)CONSTRAINED MINIMIZATION
C PROBLEMS WITH THE FOCUS ON THEIR NUMERICAL EXPRESSION USING VARIOUS
C PROGRAMMING LANGUAGES.
C
C THIS IS THE NELDER-MEAD NONLINEAR UNCONSTRAINED MINIMIZATION ALGORITHM.
C =============================================================================
C WRITTEN BY RADISLAV (RADICCHIO) GOLUBTSOV, 2015-2023
C
C THIS IS FREE AND UNENCUMBERED SOFTWARE RELEASED INTO THE PUBLIC DOMAIN.
C
C ANYONE IS FREE TO COPY, MODIFY, PUBLISH, USE, COMPILE, SELL, OR
C DISTRIBUTE THIS SOFTWARE, EITHER IN SOURCE CODE FORM OR AS A COMPILED
C BINARY, FOR ANY PURPOSE, COMMERCIAL OR NON-COMMERCIAL, AND BY ANY
C MEANS.
C
C (SEE THE LICENSE FILE AT THE TOP OF THE SOURCE TREE.)
C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
C * *
C * SEE THE NELMIN.TXT.C FILE FOR DETAILS DESCRIPTION. *
C * *
C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
C === THE USER-SUPPLIED OBJECTIVE FUNCTION F(X).
FUNCTION F(X)
IMPLICIT NONE
C CONSTANT. THE MAXIMUM NUMBER OF VARIABLES.
INTEGER VARS
PARAMETER (VARS = 20)
C RETURN VAL. THE OBJECTIVE FUNCTION VALUE.
DOUBLE PRECISION F
C ARG. THE POINT AT WHICH F(X) SHOULD BE EVALUATED.
DOUBLE PRECISION X(VARS)
#ifndef WOODS
C ROSENBROCK'S CLASSIC PARABOLIC VALLEY ('BANANA') FUNCTION.
DOUBLE PRECISION A
DOUBLE PRECISION B
A = X(2) - X(1) ** 2
B = 1 - X(1)
F = 100 * (A ** 2) + (B ** 2)
#else
C WOODS -- A LA MORE, GARBOW AND HILLSTROM (TOMS ALGORITHM 566).
DOUBLE PRECISION S1
DOUBLE PRECISION S2
DOUBLE PRECISION S3
DOUBLE PRECISION T1
DOUBLE PRECISION T2
DOUBLE PRECISION T3
DOUBLE PRECISION T4
DOUBLE PRECISION T5
S1 = X(2) - X(1) ** 2
S2 = 1 - X(1)
S3 = X(2) - 1
T1 = X(4) - X(3) ** 2
T2 = 1 - X(3)
T3 = X(4) - 1
T4 = S3 + T3
T5 = S3 - T3
F = 100 * (S1 ** 2) + (S2 ** 2)
* + 90 * (T1 ** 2) + (T2 ** 2)
* + 10 * (T4 ** 2) + (T5 ** 2) / 10
#endif
RETURN
END
C === MAIN OPTIMIZATION SUBROUTINE.
C THE NELMIN SUBROUTINE ITSELF (NELDER-MEAD MINIMIZATION).
SUBROUTINE NELMIN( F, N, START, XMIN, YNEWLO, REQMIN,
* STEP, KONVGE, KCOUNT, ICOUNT, NUMRES, IFAULT)
IMPLICIT NONE
C CONSTANT. THE MAXIMUM NUMBER OF VARIABLES.
INTEGER VARS
PARAMETER (VARS = 20)
C CONSTANT. THE REFLECTION COEFFICIENT.
DOUBLE PRECISION RCOEFF
PARAMETER (RCOEFF = 1.0D+00)
C CONSTANT. THE EXTENSION COEFFICIENT.
DOUBLE PRECISION ECOEFF
PARAMETER (ECOEFF = 2.0D+00)
C CONSTANT. THE CONTRACTION COEFFICIENT.
DOUBLE PRECISION CCOEFF
PARAMETER (CCOEFF = 0.5D+00)
C CONSTANT. THE OPTIMALITY FACTOR.
DOUBLE PRECISION EPS
PARAMETER (EPS = 0.001D+00)
C ARG. THE OBJECTIVE FUNCTION F(X).
DOUBLE PRECISION F
EXTERNAL F
C ARG. THE NUMBER OF VARIABLES.
INTEGER N
C ARG. THE STARTING POINT FOR THE ITERATION.
DOUBLE PRECISION START(VARS)
C ARG. THE COORDINATES OF THE POINT WHICH IS ESTIMATED
C TO MINIMIZE THE FUNCTION.
DOUBLE PRECISION XMIN(VARS)
C ARG. THE MINIMUM VALUE OF THE FUNCTION.
DOUBLE PRECISION YNEWLO
C ARG. THE TERMINATING LIMIT FOR THE VARIANCE
C OF FUNCTION VALUES.
DOUBLE PRECISION REQMIN
C ARG. THE SIZE AND SHAPE OF THE INITIAL SIMPLEX.
DOUBLE PRECISION STEP(VARS)
C ARG. THE CONVERGENCE CHECK.
INTEGER KONVGE
C ARG. THE MAXIMUM NUMBER OF FUNCTION EVALUATIONS.
INTEGER KCOUNT
C ARG. THE NUMBER OF FUNCTION EVALUATIONS USED.
INTEGER ICOUNT
C ARG. THE NUMBER OF RESTARTS.
INTEGER NUMRES
C ARG. THE ERROR INDICATOR.
INTEGER IFAULT
INTEGER JCOUNT
INTEGER NN
INTEGER I
INTEGER J
INTEGER ILO
INTEGER IHI
INTEGER L
DOUBLE PRECISION DN
DOUBLE PRECISION DNN
DOUBLE PRECISION DEL
DOUBLE PRECISION RQ
DOUBLE PRECISION P(VARS, VARS + 1)
DOUBLE PRECISION Y(VARS + 1)
DOUBLE PRECISION X
DOUBLE PRECISION YLO
DOUBLE PRECISION Z
DOUBLE PRECISION PBAR(VARS)
DOUBLE PRECISION PSTAR(VARS)
DOUBLE PRECISION YSTAR
DOUBLE PRECISION P2STAR(VARS)
DOUBLE PRECISION Y2STAR
C CHECK THE INPUT PARAMETERS.
IF (REQMIN .LE. 0.0D+00) THEN
IFAULT = 1
RETURN
END IF
IF (N .LT. 1) THEN
IFAULT = 1
RETURN
END IF
IF (VARS .LT. N) THEN
IFAULT = 1
RETURN
END IF
IF (KONVGE .LT. 1) THEN
IFAULT = 1
RETURN
END IF
ICOUNT = 0
NUMRES = 0
JCOUNT = KONVGE
DN = DBLE(N)
NN = N + 1
DNN = DBLE(NN)
DEL = 1.0D+00
RQ = REQMIN * DN
C CONSTRUCTION OF INITIAL SIMPLEX.
1000 CONTINUE
DO 10 I = 1, N
P(I, NN) = START(I)
10 CONTINUE
Y(NN) = F(START)
DO 20 J = 1, N
X = START(J)
START(J) = START(J) + STEP(J) * DEL
DO 30 I = 1, N
P(I, J) = START(I)
30 CONTINUE
Y(J) = F(START)
START(J) = X
20 CONTINUE
ICOUNT = ICOUNT + NN
C THE SIMPLEX CONSTRUCTION IS COMPLETE.
C FIND HIGHEST AND LOWEST Y VALUES.
C YNEWLO = Y(IHI) INDICATES THE VERTEX OF THE SIMPLEX
C TO BE REPLACED.
YLO = Y(1)
ILO = 1
DO 40 I = 2, NN
IF (Y(I) .LT. YLO) THEN
YLO = Y(I)
ILO = I
END IF
40 CONTINUE
2000 CONTINUE
YNEWLO = Y(1)
IHI = 1
DO 50 I = 2, NN
IF (YNEWLO .LT. Y(I)) THEN
YNEWLO = Y(I)
IHI = I
END IF
50 CONTINUE
C CALCULATE PBAR, THE CENTROID OF THE SIMPLEX VERTICES
C EXCEPTING THE VERTEX WITH Y VALUE YNEWLO.
DO 60 I = 1, N
Z = 0.0D+00
DO 70 J = 1, NN
Z = Z + P(I, J)
70 CONTINUE
Z = Z - P(I, IHI)
PBAR(I) = Z / DN
60 CONTINUE
C REFLECTION THROUGH THE CENTROID.
DO 80 I = 1, N
PSTAR(I) = PBAR(I) + RCOEFF * (PBAR(I) - P(I, IHI))
80 CONTINUE
YSTAR = F(PSTAR)
ICOUNT = ICOUNT + 1
C SUCCESSFUL REFLECTION, SO EXTENSION.
IF (YSTAR .LT. YLO) THEN
DO 90 I = 1, N
P2STAR(I) = PBAR(I) + ECOEFF * (PSTAR(I) - PBAR(I))
90 CONTINUE
Y2STAR = F(P2STAR)
ICOUNT = ICOUNT + 1
C CHECK EXTENSION.
IF (YSTAR .LT. Y2STAR) THEN
DO 100 I = 1, N
P(I, IHI) = PSTAR(I)
100 CONTINUE
Y(IHI) = YSTAR
C RETAIN EXTENSION OR CONTRACTION.
ELSE
DO 110 I = 1, N
P(I, IHI) = P2STAR(I)
110 CONTINUE
Y(IHI) = Y2STAR
END IF
C NO EXTENSION.
ELSE
L = 0
DO 120 I = 1, NN
IF (YSTAR .LT. Y(I)) THEN
L = L + 1
END IF
120 CONTINUE
IF (1 .LT. L) THEN
DO 130 I = 1, N
P(I, IHI) = PSTAR(I)
130 CONTINUE
Y(IHI) = YSTAR
C CONTRACTION ON THE Y(IHI) SIDE OF THE CENTROID.
ELSE IF (L .EQ. 0) THEN
DO 140 I = 1, N
P2STAR(I) = PBAR(I)
* + CCOEFF * (P(I, IHI) - PBAR(I))
140 CONTINUE
Y2STAR = F(P2STAR)
ICOUNT = ICOUNT + 1
C CONTRACT THE WHOLE SIMPLEX.
IF (Y(IHI) .LT. Y2STAR) THEN
DO 150 J = 1, NN
DO 160 I = 1, N
P(I, J) = (P(I, J) + P(I, ILO)) * CCOEFF
XMIN(I) = P(I, J)
160 CONTINUE
Y(J) = F(XMIN)
150 CONTINUE
ICOUNT = ICOUNT + NN
IF (KCOUNT .LT. ICOUNT) THEN
GO TO 3000
END IF
YLO = Y(1)
ILO = 1
DO 170 I = 2, NN
IF (Y(I) .LT. YLO) THEN
YLO = Y(I)
ILO = I
END IF
170 CONTINUE
GO TO 2000
C RETAIN CONTRACTION.
ELSE
DO 180 I = 1, N
P(I, IHI) = P2STAR(I)
180 CONTINUE
Y(IHI) = Y2STAR
END IF
C CONTRACTION ON THE REFLECTION SIDE OF THE CENTROID.
ELSE IF (L .EQ. 1) THEN
DO 190 I = 1, N
P2STAR(I) = PBAR(I)
* + CCOEFF * (PSTAR(I) - PBAR(I))
190 CONTINUE
Y2STAR = F(P2STAR)
ICOUNT = ICOUNT + 1
C RETAIN REFLECTION?
IF (Y2STAR .LE. YSTAR) THEN
DO 200 I = 1, N
P(I, IHI) = P2STAR(I)
200 CONTINUE
Y(IHI) = Y2STAR
ELSE
DO 210 I = 1, N
P(I, IHI) = PSTAR(I)
210 CONTINUE
Y(IHI) = YSTAR
END IF
END IF
END IF
C CHECK IF YLO IMPROVED.
IF (Y(IHI) .LT. YLO) THEN
YLO = Y(IHI)
ILO = IHI
END IF
JCOUNT = JCOUNT - 1
IF (JCOUNT .NE. 0) THEN
GO TO 2000
END IF
C CHECK TO SEE IF MINIMUM REACHED.
IF (ICOUNT .LE. KCOUNT) THEN
JCOUNT = KONVGE
Z = 0.0D+00
DO 220 I = 1, NN
Z = Z + Y(I)
220 CONTINUE
X = Z / DNN
Z = 0.0D+00
DO 230 I = 1, NN
Z = Z + (Y(I) - X) ** 2
230 CONTINUE
IF (RQ .LT. Z) THEN
GO TO 2000
END IF
END IF
C FACTORIAL TESTS TO CHECK THAT YNEWLO IS A LOCAL MINIMUM.
3000 CONTINUE
DO 240 I = 1, N
XMIN(I) = P(I, ILO)
240 CONTINUE
YNEWLO = Y(ILO)
IF (KCOUNT .LT. ICOUNT) THEN
IFAULT = 2
RETURN
END IF
IFAULT = 0
DO 250 I = 1, N
DEL = STEP(I) * EPS
XMIN(I) = XMIN(I) + DEL
Z = F(XMIN)
ICOUNT = ICOUNT + 1
IF (Z .LT. YNEWLO) THEN
IFAULT = 2
GO TO 4000
END IF
XMIN(I) = XMIN(I) - (DEL * 2)
Z = F(XMIN)
ICOUNT = ICOUNT + 1
IF (Z .LT. YNEWLO) THEN
IFAULT = 2
GO TO 4000
END IF
XMIN(I) = XMIN(I) + DEL
250 CONTINUE
4000 CONTINUE
IF (IFAULT .EQ. 0) THEN
RETURN
END IF
C RESTART THE PROCEDURE.
DO 260 I = 1, N
START(I) = XMIN(I)
260 CONTINUE
DEL = EPS
NUMRES = NUMRES + 1
GO TO 1000
END
C === MAIN PROGRAM.
PROGRAM AMOEBA
IMPLICIT NONE
C CONSTANT. THE MAXIMUM NUMBER OF VARIABLES.
INTEGER VARS
PARAMETER (VARS = 20)
INTEGER N
INTEGER KONVGE
INTEGER KCOUNT
INTEGER I
INTEGER ICOUNT
INTEGER NUMRES
INTEGER IFAULT
DOUBLE PRECISION START(VARS)
DOUBLE PRECISION REQMIN
DOUBLE PRECISION STEP(VARS)
DOUBLE PRECISION YNEWLO
DOUBLE PRECISION XMIN(VARS)
C PROTO REF. THE OBJECTIVE FUNCTION F(X).
DOUBLE PRECISION F
#ifndef WOODS
C STARTING GUESS FOR ROSENBROCK'S TEST FUNCTION.
PRINT 10
10 FORMAT (/, 'TEST01',
* /2X, 'Apply NELMIN to ROSENBROCK function.')
N = 2
START(1) = -1.2
START(2) = 1.0
#else
C STARTING GUESS TEST PROBLEM 'WOODS'.
PRINT 50
50 FORMAT (/, 'TEST05',
* /2X, 'Apply NELMIN to WOODS function.')
N = 4
START(1) = -3.0
START(2) = -1.0
START(3) = -3.0
START(4) = -1.0
#endif
REQMIN = 1.0D-08
STEP(1) = 1.0
STEP(2) = 1.0
#ifdef WOODS
STEP(3) = 1.0
STEP(4) = 1.0
#endif
C KONVGE AND KCOUNT HAVE SAME VALUES FOR ALL TEST PRBMS:
C SHOULD THEY BE VARIED?
KONVGE = 10
KCOUNT = 500
PRINT 60
60 FORMAT (/2X, 'Starting point X:', /)
DO 70 I = 1, N
PRINT 80, START(I), START(I)
80 FORMAT ( 2X, G14.6, 12X, '->', 4X, F20.12)
70 CONTINUE
YNEWLO = F(START)
PRINT 90, YNEWLO, YNEWLO
90 FORMAT (/2X, 'F(X) =', 1X, G14.6, 4X, '->', 4X, F20.12)
CALL NELMIN( F, N, START, XMIN, YNEWLO, REQMIN,
* STEP, KONVGE, KCOUNT, ICOUNT, NUMRES, IFAULT)
PRINT 100, IFAULT
100 FORMAT (/2X, 'Return code IFAULT =', 1X, I8)
PRINT 110
110 FORMAT (/2X, 'Estimate of minimizing value X*:', /)
DO 120 I = 1, N
PRINT 130, XMIN(I), XMIN(I)
130 FORMAT ( 2X, G14.6, 12X, '->', 4X, F20.12)
120 CONTINUE
PRINT 140, YNEWLO, YNEWLO
140 FORMAT (/2X, 'F(X*) =', 1X, G14.6, 4X, '->', 4X, F20.12)
PRINT 150, ICOUNT
150 FORMAT (/2X, 'Number of iterations =', 1X, I8)
PRINT 160, NUMRES
160 FORMAT ( 2X, 'Number of restarts =', 1X, I8)
END
|
PROGRAM QPLOT
C ********************************************************************
C * *
C * This software is an unpublished work containing confidential and *
C * proprietary information of Birkbeck College. Use, disclosure, *
C * reproduction and transfer of this work without the express *
C * written consent of Birkbeck College are prohibited. This notice *
C * must be attached to all copies or extracts of the software. *
C * *
C * (c) 1993, 1996 Oliver Smart & Birkbeck College, *
C * All rights reserved *
C * *
C ********************************************************************
C
C Modification history:
C
C Date Author Modification
C 12/93 O.S. Smart Original public release in HOLE suite beta1.0
C 10/95 O.S. Smart Overhaul making more user friendly -
C How many input files? question.
C Support for extra HOLE colours 17 to 20
C which are z of change colour record if y -55
C 28/02/97 O.S.S. Release HOLE2 beta001
C 11/97 O.S.S. vt control codes
C
C
C
C This program is designed to convert the binary plot file
C produced by Hydra or Quanta to a postscript file for printing.
C Planned features include being able to rotate image (using view
C from hydra format view file), plot stereo pictures, add text, scale
C images and possible include a simple plot interface for the vax.
C The code is written in near-standard FORTRAN77 and has been
C developed under vax-vms, iris and ibm-rs6000/aix environments.
C
C Authors Oliver Smart & Valeriu Niculae.
C
C This software is an unpublished work containing confidential and
C proprietary information of Birkbeck College. Use, disclosure,
C reproduction and transfer of this work without the express
C written consent of Birkbeck College are prohibited.
C
C (c) 1992 Birkbeck College,
C University of London; London, United Kingdom.;
C All Rights Reserved.
C
C a note as to the format of the hydra/quanta binary file to
C be added here *****
C implicit none is a non-standard fortran statement which
C forces all variables to be declared
IMPLICIT NONE
C Input and output stream numbers.
C Here set to 5 & 6 indicating the keyboard, the screen.
INTEGER NIN
PARAMETER( NIN = 5)
INTEGER NOUT
PARAMETER( NOUT= 6)
C input/output file stream
INTEGER SIN, SOUT
C filenames input, output, duplicate for input filename
C to work with when requested by the switch mode
CHARACTER*200 FINPT, FOUTPT, FINPT2
C abort indicator to be used with s/r interf
LOGICAL LABORT
C store for vectors read.
C The maximum number of colours is given by MAXCOL
C There are 16 seperate stores one for each colour.
C The maximum number of records to be stored is
C MAXST - this number must not be adjusted in run.
C n.b. rstore(0,*,*,*) a indicates 2: move to 3:draw to etc.
INTEGER MAXST
PARAMETER( MAXST = 20000)
INTEGER MAXCOL
PARAMETER( MAXCOL = 20)
INTEGER ISTORE(MAXCOL)
REAL RSTORE( MAXST, 0:3, MAXCOL)
C store for text strings
C txtno the number of strings stored
C txtlen(*) the length of string *
C txtpos(1 to 3, *) the position of its anchor point in angs space
C txtdir(*) an integer to indicate where the string should be
C placed on page 1 indicates below to the left
C 2 ............... centred etc.
C key 789
C 456 (like a numeric keypad)
C 123
C txtstr(*) the string to be written
C the maximum number of strings
INTEGER MAXTXT
PARAMETER( MAXTXT = 500)
C the maximum numbers of characters in each text string
INTEGER MAXLEN
PARAMETER( MAXLEN = 80)
INTEGER TXTNO
INTEGER TXTLEN( MAXTXT)
REAL TXTPOS( 3, MAXTXT)
INTEGER TXTDIR( MAXTXT)
CHARACTER*(MAXLEN) TXTSTR( MAXTXT)
C takes the matrix values in double array MAT3
REAL MAT3(3,3)
C Vble which passes on the information whether
C there are "dot at" records in the file:
C -1. means dots are processed into 3d crosses in s/r qreadi
C 0.0 no dots in file
C +ve number the point size for circles to which crosses processed
REAL DOTAT
C indicator for the level of control to be used
C in forming picture:
C 'E' expert full control
C 'N' normal level of control
CHARACTER *1 SWITCH
C a loop count
INTEGER ICOUNT
C one character command
CHARACTER*1 COM1
C end of declarations ********** (declarations above, exe's below)
C turn on VT codes - but not BOLD characters after prompt
CALL VTCON( .FALSE.)
C greet user
WRITE( NOUT, '(A)')
&' This is program qplot which reads quanta plot files',
&' and produces postscript output',
&' Copyright 1993,1997 by Oliver Smart',
&' Copyright 2004 by Oliver Smart ',
&' Copyright 2014-2015 SmartSci Limited, All rights reserved.'
C write link time of program to screen
CALL VERTIM( NOUT)
C what degree of difficulty should be applied ?
WRITE(NOUT, '(A)')
&' What level of questions/options do you want to be used?'
CALL PROMPT(NOUT,
& ' Options:- expert (E) or normal <normal>:')
C read answer
READ( NIN,'(A1)', END= 55555, ERR= 55555) SWITCH
CALL VTCLEAR( NOUT)
CALL UCASE(SWITCH)
IF (SWITCH.NE.'E') SWITCH ='N'
C 2/6/95 sg has problems in correctly initializing vbles
C so assign all ISTORE (number of stored move/draws) to zero
DO 10 ICOUNT = 1, MAXCOL
ISTORE(ICOUNT) = 0
10 CONTINUE
TXTNO = 0
C +--------------------------------------+
C ! Open input and output streams/files !
C +--------------------------------------+
C Ask for input filename.
C Use s/r interf this has arguments
C input stream (usually 5) returned unchanged %
C output stream (usually 6) returned unchanged %
C a logical variable if true file is old (existing) returned unchanged %
C The stream number the file is opened to - choosen by interf %
C The file type which is a short description of file -
C if this includes the string 'binary' the file will be opened
C as such - returned unchanged %
C The filename - this is supplied with default and returned
C with the name which is opened %
C An abort indicator if this is supplied .true. then the routine
C will allow the user to abort - if .false. no abort is allowed.
C An abort is indicated by labort being returned .true. %
C
C allow abort
LABORT = .TRUE.
C March 1993 - new routine to find latest file of
C type in the directory. N.b. only works on unix machines
CALL LASTF( FINPT, '.qpt')
IF (FINPT(1:4).EQ.'none') FINPT = 'input'
C N.B. as file_type includes 'BINARY' then will open as binary
CALL INTERF( NIN, NOUT, .TRUE., SIN,
& 'input binary hydra/quanta plot', FINPT, LABORT, '.qpt')
IF (LABORT) GOTO 55555
FINPT2 = FINPT
C jump here if a second or subsequent file is read
101 CONTINUE
C +-------------------------------------------+
C ! Have now opened input streams !
C ! can proceed with read !
C +-------------------------------------------+
C s/r qreadi reads the info in file into the store
C istore( 1 to maxcol) is returned with the number of move
C draws read for each colour
C rstore is the store for moves/draws
C if any problem is found in the file return abort as true
CALL QREADI( NIN, NOUT, SIN, MAXST, MAXCOL, ISTORE, RSTORE,
& MAXTXT, MAXLEN, TXTNO, TXTLEN, TXTPOS, TXTDIR, TXTSTR, LABORT,
& DOTAT, SWITCH)
C all records now read close input
CLOSE( SIN)
IF (LABORT) GOTO 55555
C tell user the total number of records read
WRITE( NOUT, '(A,I5,A)')
&' Have read a total of ',
& ISTORE( 1) + ISTORE( 2) + ISTORE( 3) + ISTORE( 4) + ISTORE( 5) +
& ISTORE( 6) + ISTORE( 7) + ISTORE( 8) + ISTORE( 9) + ISTORE(10) +
& ISTORE(11) + ISTORE(12) + ISTORE(13) + ISTORE(14) + ISTORE(15) +
& ISTORE(16) + ISTORE(17) + ISTORE(18) + ISTORE(19) + ISTORE(20) +
& TXTNO, ' records so far'
C ask whether you want another file - rather than indicating abort
C as previously - do even for simple level.
CALL PROMPT( NOUT,
& 'Do you want to read another input file? (y/n) <n>:')
C read answer
READ( NIN,'(A1)', END= 55555, ERR= 55555) COM1
CALL VTCLEAR( NOUT)
CALL UCASE(COM1)
C yes no question
IF (COM1.EQ.'Y') THEN
LABORT = .TRUE.
FINPT = 'input'
CALL INTERF( NIN, NOUT, .TRUE., SIN,
& 'input next binary hydra/quanta plot', FINPT, LABORT, '.qpt')
IF (.NOT.LABORT) THEN
C make a duplicate of the input filename in case
C the user aborts the input
FINPT2 = FINPT
C read input file and ask again
GOTO 101
ENDIF
C end of further file question
ENDIF
C now ask for output file - allow abort
LABORT = .TRUE.
C the default output file is the input name (its duplicate)
C with .ps extension
FOUTPT = FINPT2
C third vble now false - a new file to be opened
WRITE(NOUT, *)
CALL INTERF( NIN, NOUT, .FALSE., SOUT,
& 'output postscript file', FOUTPT, LABORT, '.ps')
IF (LABORT) GOTO 55555
C Does the user want to choose a different view?
C get the rotation matrix MAT3 from a hydra
C view file.
CALL QGETBI( NIN, NOUT, MAT3, LABORT)
IF (LABORT) GOTO 55555
C write( nout, '(a/3(3f8.3/)a)')
C &' (debug) rotation matrix = ', MAT3, ' (debug)'
C rotate all the stored move/draw and text anchor point
C records by the matrix MAT3 read in by QGETMX
CALL QUSEMX( NIN, NOUT, MAXST, MAXCOL, MAT3,
& LABORT, RSTORE, ISTORE, MAXTXT, TXTNO, TXTPOS)
IF (LABORT) GOTO 55555
C +--------------------------------------------+
C ! Have completed all input and done rotation !
C ! Write postscript output file !
C +--------------------------------------------+
CALL QPSWR( NIN, NOUT, SOUT, MAXST, MAXCOL, ISTORE, RSTORE,
& MAXTXT, MAXLEN, TXTNO, TXTLEN, TXTPOS, TXTDIR, TXTSTR,
& LABORT, DOTAT, SWITCH)
CLOSE( SOUT)
IF (LABORT) GOTO 55555
C stop here
55555 WRITE( NOUT, *)
STOP 'FORTRAN STOP qplot normal successful completion.'
END
|
SUBROUTINE DSPLFT( X, Y, DY, S, N, W, * )
C
C This routine interpolates and/or smooths 1 dimensional array.
C DSPLFT fits a cubic spline function to a set of data points
C (X(I),Y(I)), I = 1, N. The routine will try to achieve
C sum(i=1,N) of (g(X(i))-Y(i))**2/(DY(i)**2) < S where DY(i)>0,
C i=1,....N AND S >= 0 are given numbers and g is the cubic spline.
C This routine was taken from U.B.C *NUMLIB
C For more complete write-up see UBC CURVE p.53-58 (Mar/76)
C
C Input Parameters
C X : REAL*8 monotonically increasing array dimensioned N
C containing the abscissae of the given data points.
C Y : REAL*8 array dimensioned N containing the ordinates
C of the given data points.
C DY : REAL*8 array dimensioned N which controls the
C amount of smoothing at each abscissa. If possible
C use the standard deviation of Y(i) for DY(i)
C S : REAL*8 variable controlling "tension" of fit
C If S=0. an interpolating spline results
C N : INTEGER*4 variable containing the number of data points (N>2)
C Output Parameters
C W : REAL*8 array dimensioned 11*N+14 used for scratch
C
C Originally written by CJ Kost, Aug 5, 1980 (@SIN)
C Extensively modified by JL Chuma, March 30, 1994
C
IMPLICIT NONE
REAL*8 X(1), Y(1), DY(1), W(1), S
INTEGER*4 N
C local variables
REAL*8 DS, E, EE, F, G, H, P, SS
INTEGER*4 NCOUNT, I
CCC
IF( N .LT. 3 )RETURN 1
NCOUNT = 1
SS = S
DS = SS
EE = DS*0.5D-6
IF( S .LE. 0.0D0 )THEN
SS = 1.0D-8
EE = 0.5D-6
END IF
W(4*N+1) = 0.0D0
W(4*N+2) = 0.0D0
W(6*N+3) = 0.0D0
W(6*N+4) = 0.0D0
W(7*N+5) = 0.0D0
W(7*N+6) = 0.0D0
W(9*N+11) = 0.0D0
W(9*N+12) = 0.0D0
W(10*N+11) = 0.0D0
W(10*N+12) = 0.0D0
P = 0.0D0
H = X(2)-X(1)
IF( H .LE. 0.0D0 )RETURN 1
F = (Y(2)-Y(1))/H
DO I = 2, N-1
G = H
H = X(I+1)-X(I)
IF( H .LE. 0.0D0 )RETURN 1
E = F
F = (Y(I+1)-Y(I))/H
W(I) = F-E
W(7*N+7+I) = .66666666666667D0*(G+H)
W(8*N+9+I) = .33333333333333D0*H
W(6*N+5+I) = DY(I-1)/G
W(4*N+I+1) = DY(I+1)/H
W(5*N+3+I) = -DY(I)/G-DY(I)/H
END DO
DO I = 2, N-1
W(N+I) = W(4*N+I+1)*W(4*N+I+1)+W(5*N+3+I)*W(5*N+3+I)
& +W(6*N+5+I)*W(6*N+5+I)
W(2*N+I) = W(4*N+I+1)*W(5*N+4+I)+W(5*N+3+I)*W(6*N+6+I)
W(3*N+I) = W(4*N+I+1)*W(6*N+7+I)
END DO
C LDU decompositon
3 DO I = 2, N-1
W(5*N+2+I) = F*W(4*N+I)
W(6*N+3+I) = G*W(4*N+I-1)
W(4*N+I+1) = 1.0D0/(W(N+I)+P*W(7*N+7+I)-F*W(5*N+2+I)-
& G*W(6*N+3+I))
W(9*N+11+I) = W(I)-W(5*N+2+I)*W(9*N+10+I)-W(6*N+3+I)*W(9*N+9+I)
F = W(2*N+I)+P*W(8*N+9+I)-H*W(5*N+2+I)
G = H
H = W(3*N+I)
END DO
C back substitution
DO I = 2, N-1
W(10*N+12-I) = W(5*N+2-I)*W(10*N+12-I)
& -W(6*N+4-I)*W(10*N+13-I)-W(7*N+6-I)*W(10*N+14-I)
END DO
E = 0.0D0
H = 0.0D0
DO I = 1, N-1
G = H
H = (W(9*N+12+I)-W(9*N+11+I))/(X(I+1)-X(I))
W(10*N+13+I) = (H-G)*DY(I)*DY(I)
E = E+W(10*N+13+I)*(H-G)
END DO
G = -H*DY(N)*DY(N)
W(11*N+13) = G
E = E-G*H
IF( E.GT.DS .AND. ABS(E-DS).GT.EE )THEN
F = 0.0D0
G = 0.0D0
DO I = 2, N-1
H = W(9*N+10+I)*W(8*N+8+I)+W(9*N+11+I)*W(7*N+7+I)
& +W(9*N+12+I)*W(8*N+9+I)
F = F+W(9*N+11+I)*H
H = H-W(5*N+2+I)*W(4*N+I)-W(6*N+3+I)*W(4*N+I-1)
G = G+H*W(4*N+I+1)*H
W(4*N+I+1) = H
END DO
H = F-P*G
IF( H .GT. 0.0D0 )THEN
NCOUNT = NCOUNT+1
IF( NCOUNT .GT. 100 )RETURN 1
P = P+SQRT(E/SS)*(E-SQRT(DS*E))/H
GO TO 3
END IF
END IF
DO I = 1, N
W(I) = Y(I)-W(10*N+13+I)
W(2*N+I) = P*W(9*N+11+I)
END DO
DO I = 1, N-1
H = X(I+1)-X(I)
W(3*N+I) = (W(2*N+I+1)-W(2*N+I))/(3.0D0*H)
W(N+I) = (W(I+1)-W(I))/H-(H*W(3*N+I)+W(2*N+I))*H
END DO
RETURN
END
CCC
SUBROUTINE DSPLN( X, N, W, XX, YY, YY1, YY2, M, * )
C
C input
C X: monotonically increasing array dimensioned N
C containing the abscissae of the given data points.
C N: number of data points (N>2)
C W: array dimensioned 11*N+14 used for scratch
C XX: array length M containing the abscissae
C at which the fiited curve is to be evaluated
C Note: X(1) <= XX(I) <= X(N) for i=1,...M
C M: number of abscissae XX(i)
C
C output
C YY: array dimensioned N containing the
C returned ordinates of the function at XX(i)
C YY1: same as YY but first derivative at XX(i)
C YY2: same as YY but second derivative at XX(i)
C
IMPLICIT NONE
REAL*8 X(1), W(1), XX(1), YY(1), YY1(1), YY2(1)
INTEGER*4 N, M
REAL*8 DIFF
INTEGER*4 I, J, A, B, C, D
CCC
IF( M .LE. 0 )RETURN
J = 1
A = 1
B = A+N
C = B+N
D = C+N
DO 15 I = 1, M
11 IF( XX(I) .LT. X(J) )GO TO 14
IF( XX(I) .LT. X(J+1) )GO TO 13
IF( J .LT. N-1 )GO TO 12
IF( XX(I) .EQ. X(J+1) )GO TO 13
RETURN 1
12 J = J+1
A = J
B = A+N
C = B+N
D = C+N
GO TO 11
13 DIFF = XX(I)-X(J)
YY(I) = W(A)+DIFF*(W(B)+DIFF*(W(C)+DIFF*W(D)))
YY1(I) = W(B)+DIFF*(2.0D0*W(C)+3.0D0*DIFF*W(D))
YY2(I) = 2.0D0*W(C)+6.0D0*W(D)*DIFF
GO TO 15
14 IF( J .EQ. 1 )RETURN 1
J = 1
A = J
B = A+N
C = B+N
D = C+N
GO TO 11
15 CONTINUE
RETURN
END
|
FUNCTION betacf(a,b,x)
INTEGER MAXIT
REAL betacf,a,b,x,EPS,FPMIN
PARAMETER (MAXIT=100,EPS=3.e-7,FPMIN=1.e-30)
INTEGER m,m2
REAL aa,c,d,del,h,qab,qam,qap
qab=a+b
qap=a+1.
qam=a-1.
c=1.
d=1.-qab*x/qap
if(abs(d).lt.FPMIN)d=FPMIN
d=1./d
h=d
do 11 m=1,MAXIT
m2=2*m
aa=m*(b-m)*x/((qam+m2)*(a+m2))
d=1.+aa*d
if(abs(d).lt.FPMIN)d=FPMIN
c=1.+aa/c
if(abs(c).lt.FPMIN)c=FPMIN
d=1./d
h=h*d*c
aa=-(a+m)*(qab+m)*x/((a+m2)*(qap+m2))
d=1.+aa*d
if(abs(d).lt.FPMIN)d=FPMIN
c=1.+aa/c
if(abs(c).lt.FPMIN)c=FPMIN
d=1./d
del=d*c
h=h*del
if(abs(del-1.).lt.EPS)goto 1
11 continue
pause 'a or b too big, or MAXIT too small in betacf'
1 betacf=h
return
END
|
PROGRAM PGKEX25
C
C Define error file, Fortran unit number, and workstation type,
C and workstation ID.
C
PARAMETER (IERRF=6, LUNIT=2, IWTYPE=1, IWKID=1)
DIMENSION X(100),Y(100)
C
C Open GKS, open and activate a workstation.
C
CALL GOPKS (IERRF,IDUM)
CALL GOPWK (IWKID,LUNIT,IWTYPE)
CALL GACWK (IWKID)
C
C Define a small color table for the CGM workstation.
C
CALL GSCR(IWKID, 0, 1.0, 1.0, 1.0)
CALL GSCR(IWKID, 1, 0.4, 0.0, 0.4)
CALL GSCR(IWKID, 2, 0.0, 0.0, 1.0)
C
C Turn clipping off
C
CALL GSCLIP(0)
C
C Generate a straight line of 100 points.
C
DO 10 I=1,100
X(I) = I
Y(I) = 10.*I
10 CONTINUE
C
C Use SET to define normalization transformation 1 with linear
C scaling in the X direction and log scaling in the Y direction.
C
CALL SET(.10,.95,.20,.95,100.,1.,10.,1000.,1)
C
C Set line color to yellow.
C
CALL GSPLCI(2)
C
C Initialize the AUTOGRAPH entry EZXY so that the frame is not advanced.
C
CALL DISPLA(2,0,1)
C
C Tell EZXY that the SET ordering of the window is to be used.
C
CALL ANOTAT(' ',' ',1,4,0,' ')
C
C Output the polyline (X,Y) using EZXY.
C
CALL EZXY(X,Y,100,' ')
C
C Establish the identity transformation for character plotting.
C
CALL SET(0.,1.,0.,1.,0.,1.,0.,1.,1)
C
C Title the plot using Plotchar.
C
CALL PCSETI('FN',25)
CALL PCSETI('CC',2)
CALL PLCHHQ(.5,.09,'X Axis Reversal with SPPS',.025,0.,0.)
C
CALL FRAME
C
C Deactivate and close the workstation, close GKS.
C
CALL GDAWK (IWKID)
CALL GCLWK (IWKID)
CALL GCLKS
C
STOP
END
|
SUBROUTINE G13ADY(COV,TOR,ERR,WA,IQ1,EPSILN,MAXITN,IFAIL1)
C MARK 9 RELEASE. NAG COPYRIGHT 1981.
C MARK 11.5(F77) REVISED. (SEPT 1985.)
C
C G13ADY CALCULATES PRELIMINARY
C ESTIMATES OF MOVING AVERAGE PARAMETERS FOR G13ADZ
C (CRAMER WOLD FACTORISATION)
C
C PARAMETERS
C COV - ARRAY OF COVARIANCES, OVERWRITTEN BY
C UNSCALED RESIDUAL VARIANCE AND PARAMETERS
C IF ESTIMATION SUCCESSFUL
C TOR - M.A. PARAMETER EQUATION SOLUTIONS
C ERR - ARRAY FOR ERROR VALUES AND PARAMETER CORRECTIONS
C WA - WORKING ARRAY
C IQ1 - NO. OF PARAMETERS+1=SIZE OF ABOVE ARRAYS
C EPSILN - USED TO CALCULATE CONVERGENCE CRITERION
C MAXITN - MAXIMUM NUMBER OF ITERATIONS
C IFAIL1 - SUCCESS/FAILURE INDICATOR
C
C USES NAG LIBRARY ROUTINE G13ADX
C
C .. Scalar Arguments ..
DOUBLE PRECISION EPSILN
INTEGER IFAIL1, IQ1, MAXITN
C .. Array Arguments ..
DOUBLE PRECISION COV(IQ1), ERR(IQ1), TOR(IQ1), WA(IQ1)
C .. Local Scalars ..
DOUBLE PRECISION EPS
INTEGER I, IQMI, ITERN, J, K
C .. External Subroutines ..
EXTERNAL G13ADX
C .. Intrinsic Functions ..
INTRINSIC ABS, SQRT
C .. Executable Statements ..
EPS = EPSILN*COV(1)
ITERN = 0
TOR(1) = SQRT(COV(1))
DO 20 I = 2, IQ1
TOR(I) = COV(I)/COV(1)
20 CONTINUE
C
C CALCULATE ERRORS
C
40 DO 80 I = 1, IQ1
ERR(I) = COV(I)
IQMI = IQ1 + 1 - I
DO 60 J = 1, IQMI
K = J + I - 1
ERR(I) = ERR(I) - TOR(J)*TOR(K)
60 CONTINUE
80 CONTINUE
C
C TEST ERRORS FOR CONVERGENCE
C
DO 100 I = 1, IQ1
IF (ABS(ERR(I)).GE.EPS) GO TO 120
100 CONTINUE
GO TO 160
120 IF (ITERN.GE.MAXITN) GO TO 200
C
C CALCULATE TOR CORRECTIONS IN ERR
C
CALL G13ADX(TOR,ERR,WA,IQ1,IFAIL1)
IF (IFAIL1.NE.0) GO TO 200
C
C CORRECT TOR BY DELTA (STORED IN ERR)
C
DO 140 I = 1, IQ1
TOR(I) = TOR(I) + ERR(I)
140 CONTINUE
ITERN = ITERN + 1
GO TO 40
C
C COME HERE IF CONVERGENCE IS ACHIEVED
C
160 CONTINUE
COV(1) = TOR(1)*TOR(1)
DO 180 I = 2, IQ1
COV(I) = -TOR(I)/TOR(1)
180 CONTINUE
IFAIL1 = 0
RETURN
C
C COME HERE IF MAXIMUM ITERATIONS REACHED
C OR IF EQUATIONS HAVE NO SOLUTION
C
200 CONTINUE
IFAIL1 = 1
RETURN
END
|
c************************************************
program MODELador
c************************************************
c
c Se trata de un programa que es capaz de fabricar un fichero
c perturbado en T,Pe,H,V a partir de un modelo tau,t,pe,magfield
c definiciones
parameter (np=10000) !numero maximo de puntos en tau
character nombre*20,nomin*20
real ttau(np),tt(np),ppe(np),hh(np),MMIC(NP),VVZ(NP),
& GG(NP),FFI(NP)
real tau(np),t(np),pe(np),h(np),vz(np),MIC(NP),G(NP),FI(NP)
real xa(11),ya(11)
c ________________________________________________________________
c se abre el fichero a modificar
11 print*,'Input model atmosphere:'
read(*,'(a)')nomin
c print*,'se espera una linea de cabecera : Vmac,fill '
c print*,'los datos estan dados en tau (1),o en logtau (2): '
c read*,niflog
niflog=2
open(2,file=nomin)
c leemos la cabecera
read(2,*)vmac,fill,stray
c se lee contando las lineas
num=0
do while (num.le.999)
num=num+1
read(2,*,end=10,err=11)ttau(num),tt(num),ppe(num),MMIC(NUM),
$ hh(num),VVZ(NUM),gg(num),ffi(num)
end do
stop 'modelador.f: el modelo tiene mas de 999 puntos en tau? '
10 num=num-1
close(2)
if(niflog.eq.1)then
do i=1,num
ttau(i)=alog10(ttau(i))
end do
end if
c Que vamos a variar?
print*,'Do you want to modify the depth grid (yes=1,no=0): '
read*,nvtau
if(nvtau.eq.0)then
do i=1,num
tau(i)=ttau(i)
t(i)=tt(i)
pe(i)=ppe(i)
h(i)=hh(i)
vz(i)=vvz(i)
mic(i)=mmic(i)
g(i)=gg(i)
fi(i)=ffi(i)
end do
n=num
else
c interpolaremos las presiones en logaritmos neperianos
do i=1,num
ppe(i)=alog(ppe(i))
end do
c print*,'paso igual a cero no equiespaciado'
print*,'Give the initial log tau, final log tau and step (eg, 1.2,-4,.1): '
read*,tau1,taun,paso
paso=-paso
if(paso.eq.0)then
print*,'Number of depth points?'
read*,n
do i=1,n
print*,'Give the log tau for grid point number ',i,' :'
read*,tau(i)
end do
else
n=nint((taun-tau1)/paso)+1
c definimos la red en tau
do i=1,n
tau(i)=tau1+(i-1)*paso
end do
end if
c interpolamos
print*,'Degree of the polynomial for interpolation? '
read*,ngrado
c ngrado=2
n2=int(ngrado/2)
do i=1,n
CALL LOCATE(TTAU,NUM,TAU(I),J)
n3=j-n2-1
if(n3.lt.0)n3=0
if(n3+ngrado+1.gt.num)n3=num-ngrado-1
do k=1,ngrado+1
xa(k)=ttau(n3+k)
end do
do k=1,ngrado+1
ya(k)=tt(n3+k)
end do
CALL POLINT(XA,YA,NGRADO+1,TAU(I),T(I),ERROR)
do k=1,ngrado+1
ya(k)=ppe(n3+k)
end do
CALL POLINT(XA,YA,NGRADO+1,TAU(I),pe(I),ERROR)
do k=1,ngrado+1
ya(k)=hh(n3+k)
end do
CALL POLINT(XA,YA,NGRADO+1,TAU(I),h(I),ERROR)
do k=1,ngrado+1
ya(k)=vvz(n3+k)
end do
CALL POLINT(XA,YA,NGRADO+1,TAU(I),vz(I),ERROR)
do k=1,ngrado+1
ya(k)=mmic(n3+k)
end do
CALL POLINT(XA,YA,NGRADO+1,TAU(I),mic(I),ERROR)
do k=1,ngrado+1
ya(k)=gg(n3+k)
end do
CALL POLINT(XA,YA,NGRADO+1,TAU(I),g(I),ERROR)
do k=1,ngrado+1
ya(k)=ffi(n3+k)
end do
CALL POLINT(XA,YA,NGRADO+1,TAU(I),fi(I),ERROR)
end do
do i=1,n
pe(i)=exp(pe(i))
end do
end if
npar=-1
do while(npar.ne.0)
print*,'Which parameter do you want to modify?'
print*,'None=0,temperature=1,pressure=2,field strength=3,LOS velocity=4,'
print*,'microturbulence=5,inclination=6,azimuth=7 :'
read*,npar
if(npar.eq.0)goto 101
c print*,'entre que taus? (entre 1 y ',n,'=todos)'
c read*,i1,i2
i1=1
i2=n
print*,'The formula x_new=a+b*x_old+c*log10(tau) will be used'
print*,'Specify a , b and c '
read*,a,b,c
do i=i1,i2
if(npar.eq.1)t(i)=a+b*t(i)+c*tau(i)
if(npar.eq.2)pe(i)=a+b*pe(i)+c*tau(i)
if(npar.eq.3)h(i)=a+b*h(i)+c*tau(i)
if(npar.eq.4)vz(i)=a+b*vz(i)+c*tau(i)
if(npar.eq.5)mic(i)=a+b*mic(i)+c*tau(i)
if(npar.eq.6)g(i)=a+b*g(i)+c*tau(i)
if(npar.eq.7)fi(i)=a+b*fi(i)+c*tau(i)
end do
101 end do
c se abre el fichero en donde se escribira el modelo
print*,'Output model atmosphere? '
read(*,'(a)')nombre
open(1,file=nombre)
write(1,*)vmac,fill,stray
do i=1,n
write(1,100)tau(i),t(i),pe(i),mic(i),h(i),vz(i),g(i),fi(i)
end do
100 format(1x,f5.2,1x,f8.1,1x,1pe12.5,1x,e10.3,1x,4(e11.4,1x))
close(1)
end
|
C @(#)movnew.f 20.3 2/13/96
c
c Subroutine movnew. Re-orders one and two dimensional arrays.
c 31-Oct-94 Added three new entry points to handle double precision
c arrays: mvnew1d, movod1d and movod2d. Also added an entry point
c to handle a real array movol1r.
c
subroutine movnew (inar1, inar2, inarc, inar1d, inar2d, inar1r,
& order)
dimension inar2(2,*), inar2d(2,*), inar1(*)
dimension inar1d(*), order(*), inarc(*), inar1r(*)
c
double precision inar1d, inar2d
real inar1r
character inarc*(*)
integer order
C
include 'ipfinc/parametr.inc'
c
dimension kscr2(2,MAXBUS),kscr1(MAXBUS), scr1(MAXBUS)
dimension kscr1d(MAXBUS), kscr2d(2,MAXBUS)
c
double precision kscr1d, kscr2d
c
real scr1
c
equivalence (kscr1,kscr2,kscr1d,kscr2d,scr1)
c
character kscrc(MAXBUS)*8
save
C
C ENTRY "MVNEW2" REORDERS 2-DIMENSIONAL ARRAYS
C new = ORDER (old)
C
entry mvnew2 (inar2,order,ntot)
do 100 i = 1,ntot
j = order(i)
kscr2(1,j) = inar2(1,i)
kscr2(2,j) = inar2(2,i)
100 continue
do 110 i = 1,ntot
inar2(1,i) = kscr2(1,i)
inar2(2,i) = kscr2(2,i)
110 continue
return
C
C ENTRY "MOVOL2" REORDERS 2-DIMENSIONAL ARRAYS
C old = ORDER (new)
C
entry movol2 (inar2,order,ntot)
do 112 i = 1,ntot
j = order(i)
kscr2(1,i) = inar2(1,j)
kscr2(2,i) = inar2(2,j)
112 continue
do 114 i = 1,ntot
inar2(1,i) = kscr2(1,i)
inar2(2,i) = kscr2(2,i)
114 continue
return
C
C ENTRY "MVNEW1" REORDERS 1-DIMENSIONAL ARRAYS
C new = ORDER (old)
C
entry mvnew1 (inar1,order,ntot)
do 120 i = 1,ntot
j = order(i)
120 kscr1(j) = inar1(i)
do 130 i = 1,ntot
130 inar1(i) = kscr1(i)
return
C
C ENTRY "MOVOL1" REORDERS 1-DIMENSIONAL ARRAY
C old = ORDER (new)
C
entry movol1 (inar1,order,ntot)
do 132 i = 1,ntot
j = order(i)
kscr1(i) = inar1(j)
132 continue
do 134 i = 1,ntot
inar1(i) = kscr1(i)
134 continue
return
C
C ENTRY "MVNEWC" READERS CHARACTER ARRAYS
C new = ORDER (old)
C
entry mvnewc (inarc,order,ntot)
do 140 i=1,ntot
j=order(i)
140 kscrc(j)=inarc(i)
do 150 i=1,ntot
150 inarc(i)=kscrc(i)
return
C
C ENTRY "MOVOLC" REORDERS CHARACTER ARRAY
C old = ORDER (new)
C
entry movolc (inarc,order,ntot)
do 160 i = 1,ntot
j = order(i)
kscrc(i) = inarc(j)
160 continue
do 170 i = 1,ntot
inarc(i) = kscrc(i)
170 continue
return
C
C ENTRY "MVNEW1D" REORDERS Double Precision ARRAYS
C new = ORDER (old)
C
entry mvnew1d (inar1d,order,ntot)
do 180 i=1,ntot
j=order(i)
180 kscr1d(j)=inar1d(i)
do 190 i=1,ntot
190 inar1d(i)=kscr1d(i)
return
C
C ENTRY "MOVOL1D" REORDERS Double Precision ARRAYS
C old = ORDER (new)
C
entry movol1d (inar1d,order,ntot)
do 200 i = 1,ntot
j = order(i)
kscr1d(i) = inar1d(j)
200 continue
do 210 i = 1,ntot
inar1d(i) = kscr1d(i)
210 continue
return
C
C ENTRY "MOVOL2D" REORDERS 2-DIMENSIONAL DOUBLE PRECISION ARRAYS
C old = ORDER (new)
C
entry movol2d (inar2d,order,ntot)
do 220 i = 1,ntot
j = order(i)
kscr2d(1,i) = inar2d(1,j)
kscr2d(2,i) = inar2d(2,j)
220 continue
do 230 i = 1,ntot
inar2d(1,i) = kscr2d(1,i)
inar2d(2,i) = kscr2d(2,i)
230 continue
return
C
C ENTRY "MVNEW2D" REORDERS 2-DIMENSIONAL DOUBLE PRECISION ARRAYS
C new = ORDER (old)
C
entry mvnew2d (inar2d,order,ntot)
do 240 i = 1,ntot
j = order(i)
kscr2d(1,j) = inar2d(1,i)
kscr2d(2,j) = inar2d(2,i)
240 continue
do 250 i = 1,ntot
inar2d(1,i) = kscr2d(1,i)
inar2d(2,i) = kscr2d(2,i)
250 continue
return
C
C ENTRY "MOVOL1R" REORDERS 1-DIMENSIONAL REAL ARRAY
C old = ORDER (new)
C
entry movol1r (inar1r,order,ntot)
do 251 i = 1,ntot
j = order(i)
scr1(i) = inar1r(j)
251 continue
do 252 i = 1,ntot
inar1r(i) = scr1(i)
252 continue
return
end
|
SUBROUTINE G03AAF(MATRIX,STD,WEIGHT,N,M,X,LDX,ISX,S,WT,NVAR,E,LDE,
* P,LDP,V,LDV,WK,IFAIL)
C MARK 14 RELEASE. NAG COPYRIGHT 1989.
C MARK 16A REVISED. IER-1035 (JUN 1993).
C MARK 17 REVISED. IER-1661 (JUN 1995).
C
C PRINCIPAL COMPONENT ANALYSIS
C
C .. Parameters ..
CHARACTER*6 SRNAME
PARAMETER (SRNAME='G03AAF')
C .. Scalar Arguments ..
INTEGER IFAIL, LDE, LDP, LDV, LDX, M, N, NVAR
CHARACTER MATRIX, STD, WEIGHT
C .. Array Arguments ..
DOUBLE PRECISION E(LDE,6), P(LDP,NVAR), S(M), V(LDV,NVAR),
* WK(NVAR*NVAR+5*(NVAR-1)), WT(*), X(LDX,M)
INTEGER ISX(M)
C .. Local Scalars ..
DOUBLE PRECISION R, RN, SCALE, SRN, TEMP, WSUM
INTEGER I, IERROR, IFAULT, IND0, IVAR, J, NREC
C .. Local Arrays ..
DOUBLE PRECISION WKSP1(1,1), WKSP2(1,1)
CHARACTER*80 P01REC(2)
C .. External Functions ..
DOUBLE PRECISION DDOT, G01ECF
INTEGER P01ABF
EXTERNAL DDOT, G01ECF, P01ABF
C .. External Subroutines ..
EXTERNAL F02WEF, G03AAZ, DSCAL
C .. Intrinsic Functions ..
INTRINSIC LOG, DBLE, SQRT
C .. Executable Statements ..
NREC = 1
IERROR = 1
IF (M.LT.1) THEN
WRITE (P01REC(1),FMT=99999) M
ELSE IF (NVAR.LT.1) THEN
WRITE (P01REC(1),FMT=99983) NVAR
ELSE IF (NVAR.GT.M) THEN
WRITE (P01REC(1),FMT=99982) NVAR, M
ELSE IF (N.LT.2) THEN
WRITE (P01REC(1),FMT=99998) N
ELSE IF (NVAR.GE.N) THEN
WRITE (P01REC(1),FMT=99985) N, NVAR
ELSE IF (LDX.LT.N) THEN
WRITE (P01REC(1),FMT=99997) LDX, N
ELSE IF (LDV.LT.N) THEN
WRITE (P01REC(1),FMT=99996) LDV, N
ELSE IF (LDP.LT.NVAR) THEN
WRITE (P01REC(1),FMT=99995) LDP, NVAR
ELSE IF (LDE.LT.NVAR) THEN
WRITE (P01REC(1),FMT=99994) LDE, NVAR
ELSE IF (MATRIX.NE.'S' .AND. MATRIX.NE.'C' .AND. MATRIX.NE.
* 's' .AND. MATRIX.NE.'c' .AND. MATRIX.NE.'U' .AND.
* MATRIX.NE.'V' .AND. MATRIX.NE.'u' .AND. MATRIX.NE.'v')
* THEN
WRITE (P01REC(1),FMT=99993) MATRIX
ELSE IF (STD.NE.'S' .AND. STD.NE.'U' .AND. STD.NE.'s' .AND.
* STD.NE.'u' .AND. STD.NE.'Z' .AND. STD.NE.'z' .AND.
* STD.NE.'E' .AND. STD.NE.'e') THEN
WRITE (P01REC(1),FMT=99991) STD
ELSE IF (WEIGHT.NE.'W' .AND. WEIGHT.NE.'w' .AND. WEIGHT.NE.
* 'U' .AND. WEIGHT.NE.'u') THEN
WRITE (P01REC(1),FMT=99992) WEIGHT
ELSE
IERROR = 0
END IF
IF (IERROR.EQ.0) THEN
C
C FIND NO OF SELECTED VARIABLES
C
IVAR = 0
DO 20 I = 1, M
IF (ISX(I).GT.0) IVAR = IVAR + 1
20 CONTINUE
IF (IVAR.NE.NVAR) THEN
IERROR = 3
NREC = 2
WRITE (P01REC,FMT=99989) IVAR, NVAR
GO TO 320
END IF
C
C CHECK WEIGHTS
C
IF (WEIGHT.EQ.'W' .OR. WEIGHT.EQ.'w') THEN
WSUM = 0.0D0
SRN = 0.0D0
DO 40 I = 1, N
IF (WT(I).LT.0.0D0) GO TO 60
IF (WT(I).GT.0.0D0) THEN
WSUM = WSUM + WT(I)
V(I,IVAR) = SQRT(WT(I))
ELSE
V(I,IVAR) = 0.0D0
END IF
40 CONTINUE
IF (DBLE(IVAR).GT.WSUM-1.0D0) THEN
IERROR = 3
WRITE (P01REC(1),FMT=99988)
GO TO 320
END IF
ELSE
WSUM = DBLE(N)
END IF
GO TO 80
60 IERROR = 2
WRITE (P01REC(1),FMT=99990) I
GO TO 320
80 CONTINUE
SRN = SQRT(WSUM-1.0D0)
C
C CHECK INPUT SCALE FACTORS
C
IF (MATRIX.EQ.'S' .OR. MATRIX.EQ.'s') THEN
DO 100 J = 1, M
IF (ISX(J).GT.0) THEN
IF (S(J).LE.0.0D0) GO TO 120
END IF
100 CONTINUE
GO TO 140
120 IERROR = 4
WRITE (P01REC(1),FMT=99987) J
GO TO 320
140 CONTINUE
END IF
C
C CREATE STANDARDIZED DATA MATRIX
C
CALL G03AAZ(MATRIX,WEIGHT,N,X,LDX,M,ISX,IVAR,WT,WSUM,V,LDV,S,E)
IFAULT = 1
CALL F02WEF(N,IVAR,V,LDV,0,WKSP1,1,.TRUE.,WKSP2,1,E,.TRUE.,P,
* LDP,WK,IFAULT)
IF (IFAULT.GT.0) THEN
IERROR = 5
WRITE (P01REC(1),FMT=99986)
GO TO 320
END IF
IF (MATRIX.EQ.'V' .OR. MATRIX.EQ.'v') THEN
SCALE = 1.0D0/SRN
CALL DSCAL(IVAR,SCALE,E,1)
END IF
IF (STD.EQ.'U' .OR. STD.EQ.'u') THEN
DO 160 I = 1, IVAR
CALL DSCAL(N,E(I,1),V(1,I),1)
160 CONTINUE
ELSE IF (STD.EQ.'Z' .OR. STD.EQ.'z') THEN
DO 170 I = 1, IVAR
CALL DSCAL(N,SRN,V(1,I),1)
170 CONTINUE
ELSE IF (STD.EQ.'E' .OR. STD.EQ.'e') THEN
DO 175 I = 1, IVAR
CALL DSCAL(N,E(I,1)*SRN,V(1,I),1)
175 CONTINUE
END IF
DO 200 I = 1, IVAR
DO 180 J = I + 1, IVAR
TEMP = P(I,J)
P(I,J) = P(J,I)
P(J,I) = TEMP
180 CONTINUE
200 CONTINUE
IF (MATRIX.EQ.'C' .OR. MATRIX.EQ.'c') THEN
SCALE = DBLE(IVAR)
ELSE
SCALE = DDOT(IVAR,E,1,E,1)
END IF
IF (SCALE.LE.0.0D0) THEN
IERROR = 6
WRITE (P01REC(1),FMT=99984)
GO TO 320
END IF
E(IVAR,4) = 0.0D0
E(IVAR,5) = 0.0D0
E(IVAR,6) = 0.0D0
E(1,1) = E(1,1)*E(1,1)
E(1,2) = E(1,1)/SCALE
E(1,3) = E(1,2)
IF (IVAR.EQ.1) GO TO 320
IND0 = 1
DO 220 I = 2, IVAR
E(I,1) = E(I,1)*E(I,1)
IF (E(I,1).GT.0.0D0) IND0 = I
E(I,2) = E(I,1)/SCALE
E(I,3) = E(I-1,3) + E(I,2)
220 CONTINUE
DO 260 J = 4, 6
DO 240 I = IND0 + 1, IVAR
E(I,J) = 0.0D0
240 CONTINUE
260 CONTINUE
WK(IND0) = LOG(E(IND0,1))
WK(IVAR+IND0) = E(IND0,1)
DO 280 I = IND0 - 1, 1, -1
WK(I) = WK(I+1) + LOG(E(I,1))
WK(I+IVAR) = WK(I+IVAR+1) + E(I,1)
280 CONTINUE
RN = (WSUM-1.0D0) - DBLE(2*IVAR+5)/6.0D0
DO 300 I = 1, IND0 - 1
R = DBLE(IND0-I+1)
E(I,4) = RN*(R*LOG(WK(I+IVAR)/R)-WK(I))
E(I,5) = 0.5D0*(R-1.0D0)*(R+2.0D0)
IF (E(I,4).LE.0.0D0 .OR. MATRIX.EQ.'C' .OR. MATRIX.EQ.'c')
* THEN
E(I,6) = 0.0D0
ELSE
IFAULT = 1
E(I,6) = G01ECF('UPPER',E(I,4),E(I,5),IFAULT)
END IF
300 CONTINUE
END IF
320 IFAIL = P01ABF(IFAIL,IERROR,SRNAME,NREC,P01REC)
C
99999 FORMAT (' ** On entry, M.lt.1 : M = ',I16)
99998 FORMAT (' ** On entry, N.lt.2 : N = ',I16)
99997 FORMAT (' ** On entry, LDX.lt.N : LDX = ',I16,' N = ',I16)
99996 FORMAT (' ** On entry, LDV.lt.N : LDV = ',I16,' N = ',I16)
99995 FORMAT (' ** On entry, LDP.lt.NVAR : LDP = ',I16,' NVAR = ',I16)
99994 FORMAT (' ** On entry, LDE.lt.NVAR : LDE = ',I16,' NVAR = ',I16)
99993 FORMAT (' ** On entry, MATRIX is not valid : MATRIX = ',A1)
99992 FORMAT (' ** On entry, WEIGHT is not valid : WEIGHT = ',A1)
99991 FORMAT (' ** On entry, STD is not valid : STD = ',A1)
99990 FORMAT (' ** On entry, WT(',I16,').lt.0.0')
99989 FORMAT (' ** On entry, ',I16,' values in ISX.gt.0',/' there s',
* 'hould be NVAR = ',I16)
99988 FORMAT (' ** Number of selected variables .ge. effective number ',
* 'of observations')
99987 FORMAT (' ** On entry, S(',I16,').le.0.0')
99986 FORMAT (' ** SVD has failed to converge')
99985 FORMAT (' ** On entry, N.le.NVAR : N = ',I16,' NVAR = ',I16)
99984 FORMAT (' ** All eigenvalues are zero')
99983 FORMAT (' ** On entry, NVAR.lt.1 : NVAR = ',I16)
99982 FORMAT (' ** On entry, NVAR.gt.M : NVAR = ',I16,' M = ',I16)
END
|
C$PROG MAGNET
SUBROUTINE MAGNET
IMPLICIT REAL*8(A-H,O-Z)
c INTEGER ABSORB
character*4 ABSORB
COMMON/AAA/ V(4), NZ(30), CONST(50), ZZ(25)
DIMENSION Q(10), EL(10), TABRD(150), TABCH(150), W(10)
DIMENSION JRAK(6),TBACK(2)
DIMENSION FXFUK(2)
EQUIVALENCE (CONST(19),DEGRAD), (CONST(26),SE), (CONST(34),XA),
1(NZ(9),JRAK(1))
C
EQUIVALENCE (SOLN2 ,ZZ(1)),
& (IFLAG ,ZZ(3)),
& (TWO ,ZZ(13)),
& (ZMH ,ZZ(14)),
& (OMEGA ,ZZ(15))
C
DIMENSION IATM(4)
C
CHARACTER*4 IENGY
C
CHARACTER*320 CLWD
C
INTEGER*4 IWD(20),LWD(2,40),ITYP(40)
C
EQUIVALENCE (CLWD,LWD)
C
DATA TRUE,FALSE/1.0,0.0/
C
C
IMASS=0
IMIN=1
IMAX=80
CALL CALBRA (TABRD,TABCH,KMAX)
40 CALLED = FALSE
READ(5,55)JRAK
55 FORMAT(6A4)
READ(5,50)IWD
CALL GREAD(IWD,LWD,ITYP,NF,IMIN,IMAX,NTER)
READ(CLWD,24)DTHETA,ZOUT,EIN,FLAG,IENGY,FXFUK
READ(5,50)IWD
CALL GREAD(IWD,LWD,ITYP,NF,IMIN,IMAX,NTER)
READ(CLWD,26)ANGI
READ(5,50)IWD
CALL GREAD(IWD,LWD,ITYP,NF,IMIN,IMAX,NTER)
READ(CLWD,26)FD,TL,TR,CAL
1 IF(CALLED.NE.1.0)GO TO 52
READ(5,55)JRAK
READ(5,50)IWD
CALL GREAD(IWD,LWD,ITYP,NF,IMIN,IMAX,NTER)
READ(CLWD,24)DTHETA,ZOUT,EIN,FLAG,IENGY,FXFUK
52 CONTINUE
ISOLN2=FXFUK(1)+0.5
IA=FXFUK(2)+0.5
IF (DTHETA.EQ.0.0) GO TO 17
READ(5,50)IWD
CALL GREAD(IWD,LWD,ITYP,NF,IMIN,IMAX,NTER)
READ(CLWD,18)TARGT,TBACK,TBACKT,ZTB,FXFUK(1),ABSORB
NORDER=FXFUK(1)+0.5
READ(5,50)IWD
CALL GREAD(IWD,LWD,ITYP,NF,IMIN,IMAX,NTER)
READ(CLWD,26)W
CALLED = TRUE
IFLAG=FLAG
DTHET = DTHETA
TARGB=2*TBACKT
EI=EIN
IF (ISOLN2.EQ.2) SOLN2= TRUE
DO 2 I=1,10
Q(I)=W(I)
IF (W(I).NE.0.0) NQ=I
2 CONTINUE
IF(W(1).EQ.0.0.AND.W(2).EQ.0.0) NQ = 1
CALL PARTFI(JRAK,24,V,IATM,NZ,QGS,IFAIL,ISOR)
IF (IFAIL.EQ.0) GO TO 3
WRITE(7,28)JRAK
GO TO 1
3 XM1A=V(1)
XM2A=V(2)
XM3A=V(3)
XM4A=V(4)
CALL ENERGY (Q,EL,IENGY,QGS,NQ)
DTHETA=DTHETA*DEGRAD/2.
T=XM3A*XA
TERMX=SE/ZOUT
THDEG=ANGI
THETA=THDEG*DEGRAD
BD=FD/4.2578
C
ZT = NZ(2)
ZZ(7) = ZT
ZZ(11) = ZTB
ZPOUT = NZ(3)
ZPIN = NZ(1)
IF (TARGT.EQ.0.0) GO TO 4
IF (NORDER.EQ.1.AND.TBACKT.NE.0.0) CALL ELOSS (EIN,ZPIN,XM1A,
XZTB,TARGB,'SOLI')
c XZTB,TARGB,4HSOLI)
CALL ELOSS(EIN,ZPIN,XM1A,ZT,TARGT,ABSORB)
4 ETARG = EIN
WRITE(7,19)JRAK,QGS,EI,ETARG,XM1A,TARGT,XM2A,TBACK(1),TBACK(2),
1XM3A,TBACKT,XM4A,NORDER,ZOUT
WRITE(7,22)BD,FD
WRITE(7,20)TL,TR
WRITE(7,21)THDEG,DTHET
C
IF(SOLN2.EQ.1.0) WRITE(7,33)
IF(TWO.EQ.1.0) WRITE(7,32)
WRITE(7,31)
NOT=1
IF (W(3).EQ.0.0.AND.W(10).GT.0.0) NOT=2
GO TO 6
5 W(1)=W(1)+W(10)
IF (W(1).GT.W(2).AND.IA.EQ.1) GO TO 40
IF (W(1).GT.W(2).AND.IA.EQ.0) GO TO 1
Q(1)=W(1)
IF (IENGY.EQ.'EL ') Q(1)=QGS-W(1)
EL(1)=QGS-Q(1)
6 DO 16 J=1,NQ
CALL RELKIN (XM1A,XM2A,XM3A,XM4A,EIN,THETA,THCM3,CMTOLB,E31,Q(J),
1IJ)
IF (IJ.EQ.0.AND.IA.EQ.1) GO TO 40
IF (IJ.EQ.0.AND.IA.EQ.0) GO TO 1
IF (TARGT.EQ.0.0) GO TO 7
CALL ELOSS(E31,ZPOUT,XM3A,ZT,TARGT,ABSORB)
IF (NORDER.EQ.2.AND.TBACKT.NE.0.0) CALL ELOSS (E31,ZPOUT,XM3A,
XZTB,TARGB,'SOLI')
c XZTB,TARGB,4HSOLI)
7 RECOIL=XM1A+XM2A-XM3A-Q(J)/XA
A=TERMX*DSQRT(E31**2+2.*T*E31)/BD
IF (A-30.) 8,9,9
8 WRITE(7,29)Q(J)
GO TO 15
9 IF (A-91.) 11,11,10
10 WRITE(7,30)Q(J)
GO TO 15
11 CALL OPTIC (A,E31,XM1A,XM3A,EIN,THETA,DTHETA,RECOIL,DTFP,DEXIT,XI2
1PP,DK,ANOK)
CALL DISTAN (TL,TR,DEXIT,DTFP,XI2PP,RDIST,DELKIN)
IF (RDIST.LT.TABRD(1).AND.CAL.EQ.0.0) GO TO 12
IF (RDIST.GT.TABRD(KMAX).AND.CAL.EQ.0.0) GO TO 13
GO TO 14
12 WRITE(7,36)RDIST
GO TO 15
13 WRITE(7,35)RDIST
GO TO 15
14 CHAN=0.0
IF(CAL.EQ.0.0) CALL CHANFI (TABRD,TABCH,KMAX,RDIST,CHAN)
DELTAD = 2*DELKIN*DTHETA/ZMH*DCOS(XI2PP+OMEGA)
DELTAD = ABS(DELTAD)
WRITE(7,34)Q(J),THCM3,CMTOLB,E31,A,ANOK,DK,RDIST,EL(J),CHAN,DELKIN
X,DELTAD
15 CONTINUE
IF (NOT.EQ.2) GO TO 5
16 CONTINUE
IF(IA.EQ.1) GO TO 40
GO TO 1
C
C
18 FORMAT(E8.0,2A4,3E8.0,A4)
19 FORMAT (1H1,50X,31HOUTPUT FOR SUBROUTINE MAGNET ,///,1H ,58X,8HR
1EACTION,/,1H ,53X,6A4,/,51X,6H QGS =,F10.5,5H MEV,///,41H KINEMAT
2IC VARIABLES * * * * EBOMB(LAB) =,F10.5,5H MEV,10X,34HENERGY LOSS
3 INFO * * * * ETARGET =,F10.5,5H MEV/,37X,5H M1 =,F10.5,5H AMU,2
46X,18HTARGET THICKNESS =,F10.5,8HMG/SQ-CM,/,37X,5H M2 =,F10.5,5H
5AMU,28X,16HTARGET BACKING =,2A4,/,37X,5H M3 =,F10.5,5H AMU,24X,20
6H BACKING THICKNESS =,F10.5,8HMG/SQ-CM,/,37X,5H M4 =,F10.5,5H AMU
7,29X,15HBACKING ORDER =,I4,/,36X,6HZOUT =,F5.0,/)
20 FORMAT (//,42X,21H LEFT DIAL READING =,F10.5,/,42X,21H RIGHT DIAL
1 READING =,F10.5)
21 FORMAT (//,42X,21H REACTION LAB ANGLE =,F10.5,5H DEG,/,53X,10HAPE
1RTURE =,F10.5,5H DEG,//)
22 FORMAT (/,48X,15H MAGNET FIELD =,F10.5,11H KILOGAUSS,/,51X,12H FR
1EQUENCY =,F10.5,11H MEGAHERTZ,//)
24 FORMAT(4E8.0,A4,4X,2E8.0)
26 FORMAT(10E8.0)
28 FORMAT (14H1FINDER FAILED,10X,6A4)
29 FORMAT (1H ,17H LESS THAN 30. CM,F9.5)
30 FORMAT (1H ,17H MORE THAN 91. CM,F9.5)
31 FORMAT (1H ,8H Q VALUE,1X,10H THETA3 CM,2X,7H CMTOLB,2X,7H E3 LAB,
14X,4H RHO,2X,9H .5DE/EDT,10H KIN SHIFT,3X,6H RDIST,3X,7H ELEVEL,1X
2,12H CHANNEL NO.,1X,7H DELKIN,9H DELTA D ,/)
32 FORMAT (54H TWO SOLN TO RELKIN***PUNCH A 2 IN COL 73 OF JRAK CARD/
1)
33 FORMAT (38H CALCULATION FOR SECOND SOLN TO RELKIN,//)
34 FORMAT(1H ,F9.4, F9.3, F9.4, 2F10.4, F9.4, 3F10.4, F10.2,
1 2F10.4)
35 FORMAT (9H RDIST = ,F10.4,33H IS TO THE LEFT OF THE DETECTOR )
36 FORMAT (9H RDIST = ,F10.4,33H IS TO THE RIGHT OF THE DETECTOR )
50 FORMAT(20A4)
17 RETURN
END
|
SUBROUTINE MATCK (MFILE,PFILE,A,Z)
C
C THIS ROUTINE CHECKS THE UNIQUENESS OF MATERIAL ID'S FOR
C 1. MAT1 (1) 8. MATT1 (MB) 15. MATS1 (MC)
C 2. MAT2 9. MATT2 16. MATPZ1 (MD)
C 3. MAT3 10. MATT3 17. MTTPZ1
C 4. MAT4 11. MATT4 18. MATPZ2
C 5. MAT5 12. MATT5 19. MTTPZ2 (ME)
C 6. MAT6 13. MATT6 20. DUMC
C 7. MAT8 (MA) 14. DUMB 21. DUMD (NMAT)
C AND THE MATERIAL ID SPECIFIED ON THE PROPERTY CARDS.
C
C THIS ROUTINE SHOULD BE CALLED ONLY ONCE BY IFP.
C THIS ROUTINE DOES NOT OPEN OR CLOSE MATERIAL FILE (MFILE) OR
C ELEMENT PROPERTY FILE (PFILE)
C
C WRITTEN BY G.CHAN/UNISYS, OCT. 1982
C
LOGICAL ABORT
INTEGER PFILE, IH(3), NAME(2), Z(1), MATI(2,22)
1, GROUP, A(1), EPTI(2,40), MATJ(2,22)
COMMON /SYSTEM/ N1, NOUT, ABORT, SKIP(42), KDUM(9)
DATA MATJ / 103,-12, 203,-17, 1403,-16, 2103,-3, 2203,-8,
1 2503,-31, 603,-18,
2 703,-11, 803,-16, 1503,-16, 2303,-2, 2403,-7,
3 2603,-31, -11,-00,
4 503,-11, 1603,-07, 1803,-07, 1703,-44, 1903,-44,
5 -11,-00, -11,-00, -11,-00/
DATA EPTI / 52,191, 2502,071, 7002,071, 0502,041, 2202,041,
1 5302,041, 0602,082, 0702,103, 0802,041, 0902,061,
2 1002,041, 2102,041, 7052,171, 1102,082, 1202,103,
3 1302,041, 7032,171, 1402,041, 1502,082, 1602,051,
4 1702,041, 2002,031, 0152,243, 5102,241, 5802,174,
5 5502,-49, 5602,-06, 5702,-06, 6102,001, 6202,001,
6 6302,001, 6402,001, 6502,001, 6602,001, 6702,001,
7 6802,001, 6902,001, 0, 0, 0, 0, 0, 0/
DATA NMAT / 21/, GROUP/ 7/
DATA NEPT / 37/
DATA NAME / 4HMATC, 4HK /
C
C FIRST WORDS ON THE EPTI TABLE ARE PROPERTY CARDS THAT SPECIFY
C MATERIAL. THE FIRST 2 DIGITS OF THE SECOND WORD INDICATE THE
C NUMBER OF WORDS IN EACH PROPERTY INPUT CARD. AND THE 3RD DIGIT
C INDICATES NUMBER OF MATERIAL ID'S SPECIFIED.
C IF THIS SECOND WORD IS NEGATIVE, IT MEANS THE PROPERTY CARD IS
C OPEN-ENDED. THE 3RD DIGIT INDICATES WHERE MID1 BEGINS, AND
C REPEATING (FOR MID2, MID3,...) EVERY N WORDS WHERE N IS THE
C ABSOLUTE VALUE OF THE FIRST 2 DIGITS. (NO REPEAT OF N=0)
C
C ARRAY A CONTAINS A LIST OF ACTIVE PROPERTY IDS - SET UP BY PIDCK
C
IF (ABORT) GO TO 220
NOMAT = Z(1)
IF (NOMAT .EQ. 0) GO TO 145
C
C UPDATE EPTI ARRAY IF DUMMY ELEMENT IS PRESENT
C
DO 10 J = 1,9
IF (KDUM(J) .EQ. 0) GO TO 10
K = MOD(KDUM(J),1000)/10
EPTI(2,28+J) = K*10 + 1
10 CONTINUE
C
C SET UP POINTERS FOR THE MATI TABLE
C
MA = GROUP
MB = MA + 1
MC = MB + GROUP
MD = MC + 1
ME = MC + 4
C
C READ MATERIAL ID INTO Z SPACE, AND SAVE APPROP. COUNT IN MATI(2,K)
C
DO 15 J = 1,NMAT
MATI(1,J) = MATJ(1,J)
15 MATI(2,J) = MATJ(2,J)
J = 1
20 CALL FWDREC (*50,MFILE)
25 CALL READ (*50,*50,MFILE,IH(1),3,0,KK)
DO 30 K = 1,NMAT
IF (IH(1) .EQ. MATI(1,K)) GO TO 35
30 CONTINUE
GO TO 20
35 NWDS =-MATI(2,K)
IF (NWDS .LT. 0) CALL MESAGE (-37,0,NAME)
MATI(2,K) = 0
40 CALL READ (*50,*25,MFILE,Z(J),NWDS,0,KK)
J = J + 1
MATI(2,K) = MATI(2,K) + 1
GO TO 40
C
C INSTALL INITIAL COUNTERS IN MATI(1,K)
C
50 JX = J
IF (JX .LE. 1) GO TO 140
MATI(1,1) = 0
DO 60 J = 1,NMAT
K = J + 1
IF (MATI(2,J) .LT. 0) MATI(2,J) = 0
60 MATI(1,K) = MATI(1,J) + MATI(2,J)
C
C NOTE - ORIGINAL DATA IN MATI TABLE IS NOW DESTROYED
C
C CHECK MATERIAL ID UNIQUENESS AMONG MAT1, MAT2,..., MAT8
C (MAT4 AND MAT5 ARE UNIQUE ONLY AMONG THEMSELVES)
C
J = 0
DO 70 K = 1,MA
IF (MATI(2,K) .GT. 0) J = J + 1
70 CONTINUE
IF (J .LE. 1) GO TO 90
KK = MATI(1,MB)
K1 = KK - 1
K4 = MATI(1,4)
DO 80 K = 1,K1
J = Z(K)
IB = K + 1
DO 75 I = IB,K1
IF (J .NE. Z(I)) GO TO 75
IF (K.LT.K4 .AND. I.GE.K4) GO TO 75
CALL MESAGE (30,213,J)
ABORT =.TRUE.
GO TO 80
75 CONTINUE
80 CONTINUE
C
C CHECK MATT1, MATT2,..., MATT6 AND MATS1 MATERIAL ID
C AND THEIR CROSS REFERENCE TO MATI CARDS
C
90 DO 110 K = MB,MC
IF (MATI(2,K) .LE. 0) GO TO 110
KK = MOD(K,MA)
IB = MATI(1,KK) + 1
IE = MATI(2,KK) + IB - 1
JB = MATI(1,K ) + 1
JE = MATI(2,K ) + JB - 1
DO 105 J = JB,JE
K1 = Z(J)
IF (IE .LT. IB) GO TO 100
DO 95 I = IB,IE
IF (Z(I) .EQ. K1) GO TO 105
95 CONTINUE
100 IH(1) = K1
IH(2) = KK
K1 = 217
IF (K .EQ. 15) K1 = 17
CALL MESAGE (30,K1,IH)
ABORT =.TRUE.
105 CONTINUE
110 CONTINUE
C
C CHECK MATERIAL ID UNIQUENESS AMONG MATPZI AND MTTPZI
C
J = 0
DO 115 K = MD,ME
IF (MATI(2,K) .GT. 0) J = J + 1
115 CONTINUE
IF (J .LE. 1) GO TO 140
KK = MATI(1,ME+1)
K1 = KK - 1
NN = MATI(1,MD)
DO 130 K = NN,K1
J = Z(K)
IB = K + 1
DO 125 I = IB,KK
IF (J .NE. Z(I)) GO TO 125
CALL MESAGE (30,213,J)
ABORT =.TRUE.
GO TO 130
125 CONTINUE
130 CONTINUE
C
C NOW, WE CONTINUE TO CHECK MATERIAL ID'S ON MOST PROPERTY CARDS.
C (MATERIAL ID'S ARE ON THE 2ND, 4TH, AND 6TH POSITIONS OF THE
C PROPERTY CARDS, EXECPT THE OPEN-ENDED PCOMPI GROUP)
C
140 JE = MATI(1,NMAT)
II = A(1)
145 CALL FWDREC (*220,PFILE)
150 CALL READ (*220,*220,PFILE,IH(1),3,0,KK)
DO 160 K = 1,NEPT
IF (IH(1) .EQ. EPTI(1,K)) GO TO 170
160 CONTINUE
GO TO 145
170 IF (NOMAT .EQ. 0) GO TO 230
NWDS= EPTI(2,K)/10
NN = EPTI(2,K) - NWDS*10
IB = 1
IE = NN*2
IC = 2
KOMP= 0
C
C CHANGE NWDS, IB, IE, AND IC IF PROPERTY CARD IS OPEN-ENDED
C WHERE (IB+JX) POINTS TO THE FIRST MID POSITION
C
IF (EPTI(2,K) .GT. 0) GO TO 180
KOMP= 1
IB =-NN - 1
IC =-NWDS
IF (NWDS .EQ. 0) IC = 9999
NWDS= 10
180 IF (KOMP .EQ. 1) IE = JX + NWDS - 1
C
C READ IN PROPERTY CARD. IF ID IS NOT ON ACTIVE LIST, SKIP IT.
C SKIP IT TOO IF IT HAS NO MATERIAL ID REQUESTED.
C (NO CORE SIZE CHECK HERE. SHOULD HAVE PLENTY AVAILABLE)
C
CALL READ (*220,*150,PFILE,Z(JX),NWDS,0,KK)
IF (KOMP .EQ. 0) GO TO 182
181 IE = IE + 1
CALL READ (*220,*150,PFILE,Z(IE),1,0,KK)
IF (Z(IE) .NE. -1) GO TO 181
IE = IE - 1 - JX
182 DO 183 I = 2,II
IF (Z(JX) .EQ. A(I)) GO TO 185
183 CONTINUE
GO TO 180
185 DO 210 I = IB,IE,IC
KK = Z(JX+I)
IF (IE.EQ.8 .AND. I.EQ.7) KK = Z(JX+I+3)
IF (KK .EQ. 0) GO TO 210
IF (JX .LE. 1) GO TO 200
DO 190 J = 1,JE
IF (KK .EQ. Z(J)) GO TO 210
190 CONTINUE
200 IH(1) = KK
IH(2) = Z(JX)
CALL MESAGE (30,215,IH)
ABORT =.TRUE.
210 CONTINUE
GO TO 180
220 RETURN
C
230 CALL MESAGE (30,16,IH)
ABORT =.TRUE.
RETURN
END
|
double precision mpol,mmon,gamm
common/monopar/mpol,mmon,gamm
|
SUBROUTINE PREFFT (GAMMA)
C-----------------------------------------------------------------------
C! Convex Pseudo AP routine: Initialize FFT tables for QXFOUR.
C# AP-FFT
C-----------------------------------------------------------------------
C; Copyright (C) 1995
C; Associated Universities, Inc. Washington DC, USA.
C;
C; This program is free software; you can redistribute it and/or
C; modify it under the terms of the GNU General Public License as
C; published by the Free Software Foundation; either version 2 of
C; the License, or (at your option) any later version.
C;
C; This program is distributed in the hope that it will be useful,
C; but WITHOUT ANY WARRANTY; without even the implied warranty of
C; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
C; GNU General Public License for more details.
C;
C; You should have received a copy of the GNU General Public
C; License along with this program; if not, write to the Free
C; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
C; MA 02139, USA.
C;
C; Correspondence concerning AIPS should be addressed as follows:
C; Internet email: aipsmail@nrao.edu.
C; Postal address: AIPS Project Office
C; National Radio Astronomy Observatory
C; 520 Edgemont Road
C; Charlottesville, VA 22903-2475 USA
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C Initializes the tables used by the FFT routine QXFOUR.
C Inputs:
C GAMMA I The max. power of two for which the tables
C are to be initilized.
C Common tables /REV/:
C WMAX, BMAX PARAMETERs
C WREAL R(WMAX) Array of coefficients generated by PREFFT.
C WIMAG R(WMAX) Array of coefficients generated by PREFFT.
C BITREV I(WMAX) Array generated by PREFFT containing indices
C to bit reverse the output vector.
C Note: these dimensions are good for up to 4096 FFTs
C-----------------------------------------------------------------------
C Declare arguments & parameters
INTEGER GAMMA, GMAX, BMAX, WMAX
C Set maximum FFT size to 4096
C or GAMMA = 12 (i.e., 2**GAMMA)
PARAMETER (GMAX=12)
C Set BMAX as BTABL2(GMAX+1)
C and WMAX as BTABL(GMAX+1)
C (see DATA statements below)
PARAMETER (BMAX=8190)
PARAMETER (WMAX=37768)
C Declare local variables
INTEGER ISIGN, IPASS, IGAMMA, BASE, ORDER, INDEX, I, J, K, L,
* M, N, LN2, ITMP, JTMP
REAL PI2
C /REV/ declarations
INTEGER BITREV(BMAX)
REAL WREAL(WMAX), WIMAG(WMAX)
INTEGER BTABL(14), BTABL2(14), IFIRST, GTABL(14), GLAST
COMMON /REV/ BITREV, WREAL, WIMAG, BTABL, BTABL2, IFIRST,
* GTABL, GLAST
C Data inititialization
C BTABL(15) would be 181128
DATA BTABL /0, 0, 0, 4, 20, 68, 196, 516, 1284, 3076, 7172,
* 17288, 37768, 82824/
C BTABL2(15) would be 32766
DATA BTABL2 /0, 2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046,
* 4094, 8190, 16382/
C GTABL(15) would be 32768
DATA GTABL /2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048,
* 4096, 8192, 16384/
DATA IFIRST /0/
C-----------------------------------------------------------------------
C Sanity test
IF ((GAMMA.LT.1).OR.(GAMMA.GT.GMAX)) THEN
PRINT *,'PREFFT: GAMMA = ',GAMMA,' OUT OF RANGE'
STOP
END IF
C Only initialize on first call
C or increased GAMMA
IF ((IFIRST.NE.0).AND.(GAMMA.LE.GLAST)) GO TO 999
C Set IFIRST and GLAST for
C future calls
IFIRST = 1
GLAST = GAMMA
C Initialize bit-reversal index
C array
DO IGAMMA = 1,GAMMA
N = 2**IGAMMA
J = 0
BASE = BTABL2(IGAMMA)
DO I = 1,N
CALL REVERSE (K, J, IGAMMA)
BITREV(BASE+I) = K + 1
J = J + 1
END DO
END DO
C Initialize FFT coefficients:
C W(P,N) = COS2*PI*P/N -
C J SIN2*PI*P/N
C
C First two passes are built
C into algorithm so that
C coefficients are necessary
C for only later passes.
PI2 = 2*3.1415926535
DO IGAMMA = 3,GAMMA
K = 0
N = GTABL(IGAMMA)
LN2 = N/2
BASE = BTABL(IGAMMA)
DO I = 1,IGAMMA-2
DO J = 1,LN2
JTMP = J - 1
ITMP = I + 1
CALL REVERSE (K, JTMP, ITMP)
K = K*(GTABL(((IGAMMA-2)-I)))
WREAL(J+((I-1)*LN2+BASE)) = COS((PI2/N)*K)
WIMAG(J+((I-1)*LN2+BASE)) = -SIN((PI2/N)*K)
END DO
END DO
END DO
C
999 RETURN
END
|
program T02_1941559
!-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
!-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- Creado por Diego Alejandro Tellez Martinez -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
!-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- 1941559 -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- -_-_-_-_-_-_-_-_-_-_-
!-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- Fecha 23/01/20 -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
!-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
!Funcion de Programa: Programa que lee un numero real y encuentra su raiz cuadrada, el valor de e elevado a ese numero y su tangente
!Apendice de Variables
!-__- Enteros: n (Valor a leer), sq (Raiz del numero),ex(el exponencial a ese numero),tan (tangente del numero)
!-__-__- Reales:
! -__-__-__- Caracteres:
! -__-__-__-__- Arreglos:
Implicit none
Real:: n,sq,ex,tn
write(*,*) "Escribe el numero"
read (*,*) n
sq = (n)**.5
ex = exp(n)
tn = tan(n)
Write (*,*) "Presiona enter para obtener los valores"
write (*,*) "La raiz del numero es" , sq
write (*,*) "El valor de e elevado a ese numero es" , ex
write (*,*) "La tangente de dicho numero es" , tn
end program
|
subroutine syminverse( a, n )
implicit none
integer :: n
double precision :: a( n, n )
!D for debug use when n = 2
!D
!D double precision :: b( n, n )
!D double precision :: c( n, n )
double precision work2( 2 * n )
double precision work( n )
integer ipiv( n )
character*1 uplo
integer lda
integer lwork
integer info
integer i, j, k
!D a( 1, 1 ) = 2.0
!D a( 1, 2 ) = 1.0
!D a( 2, 1 ) = 1.0
!D a( 2, 2 ) = 2.0
!D do i = 1, n
!D do j = 1, i - 1
!D a(i, j) = 0.0d0
!D end do
!D end do
!D write(*,*) a
!D b = a
uplo = 'U'
lda = n
lwork = n
call dsytrf( uplo, n, a, lda, ipiv, work, lwork, info )
! write(*,*)a
! write(*,*)info
! write(*,*)lwork
! write(*,*)work
call dsytri( uplo, n, a, lda, ipiv, work2, info )
do i = 1, n
do j = 1, i - 1
a(i, j) = a(j, i)
enddo
enddo
!D c = 0.0d0
!D do i = 1, 2
!D do j = 1, 2
!D do k = 1, 2
!D c(i,k) = c(i,k) + b(i,j) * a(j,k)
!D enddo
!D enddo
!D enddo
!D
!D write(*,*)c
!D stop
end subroutine syminverse
|
program arithif
c Aritmethic if
read*,i
if (i) 10, 20, 30
10 print*,'Number is negative'
stop
20 print*,'Zero'
stop
30 print*,'Number is positive'
stop
end
|
PROGRAM C05EX13
PARAMETER (PI = 3.1415926)
WRITE(*, 10) SINH(60.0*PI/180.0) ! 1.24937
10 FORMAT(F8.5)
WRITE(*, 20) SINH(45.0*PI/180.0) ! 0.86867
20 FORMAT(F8.5)
WRITE(*, 30) SINH(-1.0) ! -1.17520
30 FORMAT(F8.5)
WRITE(*, 40) SINH(4.0) ! 27.28992
40 FORMAT(F8.5)
END
|
*
* $Id: sfchan_direction.F,v 1.1 2002/09/05 18:54:12 dpp Exp $
*
* $Log: sfchan_direction.F,v $
* Revision 1.1 2002/09/05 18:54:12 dpp
* -> NEW ROUTINE
* -> PROCEDURE TO SET-DIRECTION-ADDRESSES
*
*
*
#include "sys/CLEO_machine.h"
#include "pilot.h"
*-- Author : DAN PETERSON
SUBROUTINE SFCHAN_DIRECTION(FORWARDS)
C......................................................................
C.
C. SFCHAN_DIRECTION - set up control of direction for SFCHAN
C.
C. COMMON : /STEPCn/
C. CALLS :
C. CALLED : SFCHAN
C. AUTHOR : D. Peterson
C. VERSION : 1.00
C. CREATED : 30-MAY-02
C.
C......................................................................
#if defined(CLEO_TYPCHK)
IMPLICIT NONE
#endif
SAVE
C this will include tfindpar, cdgeompa, cdgeomcd, cdraw1in,
C tfctlcde, usbank,
C sfpar, sfcom, and sfsvcom
#define SF_DATA_INCLUDES
#include "doit/sf_data_access/sf_data_access.inc"
#include "doit/sfseq/sfchan_ctl.inc"
#if defined(CLEO_XTSUBS)
#include "doit/sfseq/xts_cntl.inc"
#endif
C-----------------------------------------------------------------------
C VARIABLES WITHIN SF_DATA_ACCESS
C-----------------------------------------------------------------------
#define SF_DATA_DECLARE
#include "doit/sf_data_access/sf_data_access.inc"
C-----------------------------------------------------------------------
C ARGUMENT VARIABLE DOCUMENTION
C-----------------------------------------------------------------------
C FORWARDS.....INPUT LOGICAL, if TRUE, set up for bacwards runnning
LOGICAL FORWARDS
C-----------------------------------------------------------------------
C LOCAL VARIABLE DOCUMENTION
C-----------------------------------------------------------------------
C================================================================
C================================================================
C
C ----------- Executable code starts here ---------------
C
C================================================================
C================================================================
C=======================================================================
C PROCEDURE TO SET-DIRECTION-ADDRESSES
C=======================================================================
IF(FORWARDS)THEN
IDIRSF=+1
CFOR=0
CLIN=0
ENDLO=1
C BACKWARDS
ELSE
IDIRSF=-1
CFOR=MHITSF
CLIN=MCHAIN
ENDLO=2
ENDIF
CBAK=MHITSF-CFOR
CMIN=MCHAIN-CLIN
ENDHI=3-ENDLO
RETURN
END
|
C MEMBER FRAC26
C (from old member FCFRAC26)
C***********************************************************************
FUNCTION FRAC26(DIFQI,DIFQOK,QI1,QO1,QOK1,QSFRAC,S1,SFILL,IBUG)
C***********************************************************************
C FUNCTION FRAC26 COMPUTES THE FRACTION OF THE TIME PERIOD IN SUBROUTINE
C OVER26 THAT IS REQUIRED BEFORE ROUTING BEGINS (RISING POOL) OR ROUTING
C ENDS (FALLING POOL). THE QUADRATIC EQUATION IS USED TO SOLVE THE
C EQUATION. THE EQUATION IS IN THE FORM (A*X**2+B*X+C=0.). X IS THE
C DESIRED FRACTION OF THE TIME PERIOD.
C***********************************************************************
C THIS FUNCTION WAS ORIGINALLY PROGRAMMED BY
C WILLIAM E. FOX -- CONSULTING HYDROLOGIST
C DECEMBER, 1981
C***********************************************************************
C FUNCTION FRAC26 IS IN
C***********************************************************************
C VARIABLES IN THE ARGUMENT LIST ARE AS FOLLOWS:
C DIFQI -- INFLOW AT END MINUS INFLOW AT BEGINNING OF TIME PERIOD.
C DIFQOK - NON-SPILLWAY DISCHARGE AT END MINUS NON-SPILLWAY
C DISCHARGE AT BEGINNING OF TIME PERIOD.
C QI1 -- INFLOW AT BEGINNING OF TIME PERIOD.
C QO1 -- TOTAL DISCHARGE AT BEGINNING OF TIME PERIOD.
C QOK1 -- NON-SPILLWAY DISCHARGE AT BEGINNING OF TIME PERIOD.
C QSFRAC -- SPILLWAY DISCHARGE AT TIME POOL IS FILLED TO (OR FALLS
C TO) LEVEL OF PASSING INFLOW OR UNCONTROLLED SPILLWAY CREST.
C S1 -- POOL STORAGE AT BEGINNING OF TIME PERIOD. UNITS MUST BE
C MEAN DISCHARGE FOR TIME PERIOD.
C SFILL -- STORAGE AT POOL LEVEL FOR PASSING INFLOW FOR GATED
C SPILLWAY OR STORAGE AT CREST ELEVATION FOR UNCONTROLLED SPILL-
C WAY. SAME UNITS AS S1.
C IBUG -- NO TRACE OR DEBUG (IBUG=0), TRACE ONLY (IBUG=1),TRACE AND
C DEBUG (IBUG=2).
C
COMMON/FDBUG/IODBUG,ITRACE,IDBALL,NDEBUG,IDEBUG(20)
COMMON/IONUM/IN,IPR,IPU
COMMON/ERRDAT/IOERR,NWARN,NERRS
COMMON/WHERE/ISEG(2),IOPNUM,OPNAME(2)
C ADDITION FOR MAINTENANCE 290
COMMON/NWRN26/NWFRAC
C
C ================================= RCS keyword statements ==========
CHARACTER*68 RCSKW1,RCSKW2
DATA RCSKW1,RCSKW2 / '
.$Source: /fs/hseb/ob72/rfc/ofs/src/fcst_res/RCS/frac26.f,v $
. $', '
.$Id: frac26.f,v 1.1 1995/09/17 19:05:44 dws Exp $
. $' /
C ===================================================================
C
IF(IBUG-1)50,10,20
10 WRITE(IODBUG,30)
GO TO 50
20 WRITE(IODBUG,30)
30 FORMAT(1H0,10X,17H** FRAC26 ENTERED)
WRITE(IODBUG,40)DIFQI,DIFQOK,QI1,QO1,QOK1,QSFRAC,S1,SFILL,IBUG
40 FORMAT(1H0,47H DIFQI,DIFQOK,QI1,QO1,QOK1,QSFRAC,S1,SFILL,IBUG/1X,
$8F12.3,I6)
C***********************************************************************
C COMPUTE A, B, ANC C.
C***********************************************************************
50 A=DIFQI-DIFQOK
B=2.*QI1-QO1-QOK1-QSFRAC
C=-2.*(SFILL-S1)
C***********************************************************************
C CHECK IF A IS OR IS NOT EQUAL TO 0.
C***********************************************************************
IF(A.NE.0.) GO TO 60
C***********************************************************************
C A IS EQUQL TO 0. SOLVE THE EQUATION: BX+C=0.
C***********************************************************************
X=-C/B
GO TO 70
C***********************************************************************
C WHEN A IS NOT EQUAL TO 0., SOLVE THE QUADRATIC EQUATION:
C X=(-B-(B*B-4*A*C)**0.5)/(2.*A) AND SEE IF THE ROOT IS BETWEEN 0.0 AND
C 1.0. (B*B-4*A*C) MUST FIRST BE CHECKED FOR A NEGATIVE VALUE.
C***********************************************************************
60 Y=B*B-4*A*C
IF(Y.LT.0.) GO TO 80
X=(-B-(B*B-4*A*C)**0.5)/(2.*A)
IF(X.GE.0.0.AND.X.LE.1.0) GO TO 110
C***********************************************************************
C SINCE X IS NOT BETWEEN 0. AND 1.0, SOLVE THE QUADRATIC EQUATION:
C X=(-B+(B*B-4*A*C)**0.5)/(2.*A)
C***********************************************************************
X=(-B+(B*B-4*A*C)**0.5)/(2.*A)
70 IF(X.GE.0.0.AND.X.LE.1.0) GO TO 110
80 CONTINUE
IF (X.LE.0.0) X=0.
IF (X.GT.0.0) X=1.0
C EJV MODIFY FOR MAINTENANCE 290
C ONLY PRINT FOLLOWING WARNING ONCE PER SEGMENT (VARIABLE NWFRAC
C KEEPS TRACK OF NUMBER OF WARNINGS). ALSO DONT PRINT THE WARNING
C IF C=0 AND DIFQ1 LE 0 WHICH MEANS THAT POOL IS NOT HI ENOUGH
C FOR SPILLWAY AND INFLOW IS DROPPING SO FRACTION SHOULD BE 0 FOR
C NO SPILLWAY THIS TIME PERIOD
IF (ABS(C).LT.0.00001 .AND. DIFQI.LE.0.0) GO TO 110
NWFRAC=NWFRAC+1
IF (NWFRAC.GT.1) GO TO 110
WRITE(IPR,90) X
90 FORMAT(1H0,10X,'**WARNING** IN FRAC26-COMPUTATION OF FRACTION',
$ 'OF TIME DAM IS IN SPILWAY MODE WASNT IN RANGE 0-1 FOR'
$ /10X,'GIVEN TIME PERIOD. SO FRACTION IS SET EQUAL TO',
$ F4.1,'...ITS ALL OK, NO NEED TO WORRY BABY')
CALL WARN
C END EJV MODIFY
110 FRAC26=X
IF(IBUG-1)160,140,120
120 WRITE(IODBUG,130)X
130 FORMAT(1H0,27H FRACTION OF TIME PERIOD IS,F12.3)
140 WRITE(IODBUG,150)
150 FORMAT(1H0,10X,17H** LEAVING FRAC26)
160 RETURN
END
|
PROGRAM MAIN
COMMON REAL N,M,K
REAL T,I,J
REAL Y(100,100), X(100,100), Z(100,100)
WRITE(6,*)'MULTIPLICATION OF Y(N,M) AND X(K,N) MATRICES WHERE Y(N,
* M) REPRESENTS N=NUMBER OF COLUMNS AND M=NUMBER OF ROWS'
! * IS CONTINUATION CHARACTER
READ*, N,M,K
WRITE(6,*) 'N=',N,'M=',M,'K=',K
!IF YOU DO NOT INITIALIZE A MATRIX IT WILL TAKE ALL ELEMENTS ZERO(0)
!INPUT MATRIX ELEMENTS WITH COMPLETING ROW FIRST AND THEN GO TO SECOND ROW
INYILOOP: DO I=1,M
INYJLOOP: DO J=1,N
READ*, Y(J,I)
END DO INYJLOOP
END DO INYILOOP
YILOOP: DO I = 1,N
YJLOOP: DO J=1,M
WRITE(6,*) '[',I,',',J,']','TH ELEMENT OF Y IS', Y(I,J)
END DO YJLOOP
END DO YILOOP
INXILOOP: DO I = 1,N
INXJLOOP: DO J=1,K
READ*, X(J,I)
END DO INXJLOOP
END DO INXILOOP
XILOOP: DO I = 1,K
XJLOOP: DO J=1,N
WRITE(6,*) '[',I,',',J,']','TH ELEMENT OF X IS', X(I,J)
END DO XJLOOP
END DO XILOOP
CALL SUBROUTINE MULTIPLICATION (Y,X)
WRITE(6,*)'/ MULTIPLICATION IS /'
ZILOOP: DO I = 1,K
ZJLOOP: DO J=1,M
WRITE(6,*) '[',I,',',J,']','TH ELEMENT OF Z IS', Z(I,J)
END DO ZJLOOP
END DO ZILOOP
END
SUBROUTINE MULTIPLICATION (Y,X)
COMMON REAL Z(100,100)
DO 100 T=1,K
DO 200 J=1,M
DO 300 I=1,N
300 Z(T,J)= Z(T,J) +Y(I,J)*X(T,I)
200 CONTINUE
100 CONTINUE
RETURN
END
! COMMON REAL N,M,K
! REAL T,I,J
! REAL Y(100,100), X(100,100),Z(100,100)
!
! WRITE(6,*)'MULTIPLICATION OF Y(N,M) AND X(K,N) MATRICES WHERE Y(N,
! * M) REPRESENTS N=NUMBER OF COLUMNS AND M=NUMBER OF ROWS'
!
! ! * IS CONTINUATION CHARACTER
!
! READ*, N,M,K
! WRITE(6,*) 'N=',N,'M=',M,'K=',K
!
! !IF YOU DO NOT INITIALIZE A MATRIX IT WILL TAKE ALL ELEMENTS ZERO(0)
!
! !INPUT MATRIX ELEMENTS WITH COMPLETING ROW FIRST AND THEN GO TO SECOND ROW
!
! INYILOOP: DO I=1,M
! INYJLOOP: DO J=1,N
! READ*, Y(J,I)
! END DO INYJLOOP
! END DO INYILOOP
!
! YILOOP: DO I = 1,N
! YJLOOP: DO J=1,M
! WRITE(6,*) '[',I,',',J,']','TH ELEMENT OF Y IS', Y(I,J)
! END DO YJLOOP
! END DO YILOOP
!
! INXILOOP: DO I = 1,N
! INXJLOOP: DO J=1,K
! READ*, X(J,I)
! END DO INXJLOOP
! END DO INXILOOP
!
! XILOOP: DO I = 1,K
! XJLOOP: DO J=1,N
! WRITE(6,*) '[',I,',',J,']','TH ELEMENT OF X IS', X(I,J)
! END DO XJLOOP
! END DO XILOOP
!
! DO 100 T=1,K
! DO 200 J=1,M
! DO 300 I=1,N
!300 Z(T,J) = Z(T,J) +Y(I,J)*X(T,I)
!200 CONTINUE
!100 CONTINUE
!
! WRITE(6,*)'/ MULTIPLICATION IS /'
!
! ZILOOP: DO I = 1,K
! ZJLOOP: DO J=1,M
! WRITE(6,*) '[',I,',',J,']','TH ELEMENT OF Z IS', Z(I,J)
! END DO ZJLOOP
! END DO ZILOOP |
subroutine primlst
x (idnode,mxnode,natms,imcon,rprim,lentry,list,
x cell,xxx,yyy,zzz,xdf,ydf,zdf)
c
c*************************************************************************************
c
c dlpoly routine to split interaction list into primary and secondary
c neighbours for use with multiple timestep method
c
c copyright daresbury laborartory
c
c author - t. forester february 1993
c
c wl
c 2000/01/18 14:05:52
c 1.3
c Exp
c
c************************************************************************************
#include "dl_params.inc"
dimension xxx(mxatms),yyy(mxatms),zzz(mxatms)
dimension xdf(mxxdf),ydf(mxxdf),zdf(mxxdf)
dimension lentry(msatms),list(msatms,mxlist)
dimension cell(9)
#ifdef VAMPIR
call VTBEGIN(82, ierr)
#endif
rprim2 = rprim*rprim
ii = 0
do i = 1+idnode,natms,mxnode
ii = ii + 1
do j = 1,lentry(ii)
k = iabs(list(ii,j))
xdf(j) = xxx(i) - xxx(k)
ydf(j) = yyy(i) - yyy(k)
zdf(j) = zzz(i) - zzz(k)
enddo
c
c apply minimum image convention
call images(imcon,0,1,lentry(ii),cell,xdf,ydf,zdf)
c assign atoms as primary or secondary
do j = 1,lentry(ii)
c calculate interatomic distance
rsq = xdf(j)**2+ydf(j)**2+zdf(j)**2
if(rsq.lt.rprim2)then
list(ii,j) = -iabs(list(ii,j))
c compile primary neighbour list array : -ve indices
else
list(ii,j) = iabs(list(ii,j))
c compile secondary neighbour list array : +ve indices
endif
enddo
enddo
#ifdef VAMPIR
call VTEND(82, ierr)
#endif
return
end
|
DIMENSION IDEX(200), NVECT(200), XSIZE(200), YSIZE(200), X0(2300),
* Y0(2300), X1(2300), Y1(2300)
DIMENSION RVAL(4)
CHARACTER*32FILE1, FILE2
INTEGER OUTFONT
LOGICAL FIRST, LAST
INFONT = 12
OUTFONT = 13
10 FORMAT(1X, A)
2000 CONTINUE
WRITE(6, 10) '_Enter input font file name:'
READ(5, '(a)') FILE1
OPEN(UNIT = INFONT, FILE = FILE1, STATUS = 'old', IOSTAT = IOS)
IF (IOS .NE. 0) THEN
WRITE(6, *) ' Couldn''t open input font file; re-enter'
STOP
ENDIF
GOTO 2020
2010 GOTO 2000
2020 CONTINUE
2030 CONTINUE
WRITE(6, 10) '_Enter output font file name:'
READ(5, '(a)') FILE2
OPEN(UNIT = OUTFONT, FILE = FILE2, STATUS = 'new', FORM = 'unfor
*matted', IOSTAT = IOS)
IF (IOS .NE. 0) THEN
WRITE(6, *) ' Couldn''t open output font file; re-enter'
STOP
ENDIF
GOTO 2050
2040 GOTO 2030
2050 CONTINUE
READ(INFONT, *, ERR=20) CHSP
READ(INFONT, *, ERR=20) POINT
DO 2060 IC = 1, 2
LAST = .FALSE.
NTOTVC = 0
FIRST = .TRUE.
NLOCVC = 0
XMAX = 0.
YMAX = 0.
MAXVECT = 0
2080 CONTINUE
READ(INFONT, *, END=100, ERR=20) (RVAL(I), I = 1, 4)
IF (RVAL(1) .EQ. -99.) THEN
IF (FIRST) THEN
FIRST = .FALSE.
ICH = RVAL(4)
IDEX(ICH) = 1
GOTO 2090
ELSE
IF (RVAL(4) .EQ. 999.) THEN
LAST = .TRUE.
GOTO 2100
ENDIF
IF (ICH .GT. 32) THEN
XSIZE(ICH) = (XMAX + CHSP)/POINT
ELSE
XSIZE(ICH) = (XMAX)/POINT
ENDIF
YSIZE(ICH) = YMAX/POINT
NVECT(ICH) = NLOCVC
IF (MAXVECT .LT. NLOCVC) THEN
MAXVECT = NLOCVC
MAXCHR = ICH
ENDIF
ICH = RVAL(4)
IDEX(ICH) = NTOTVC + 1
XMAX = 0.
YMAX = 0.
NLOCVC = 0
ENDIF
ELSE
NTOTVC = NTOTVC + 1
NLOCVC = NLOCVC + 1
X0(NTOTVC) = RVAL(1)/POINT
Y0(NTOTVC) = RVAL(2)/POINT
X1(NTOTVC) = RVAL(3)/POINT
Y1(NTOTVC) = RVAL(4)/POINT
IF (RVAL(1) .GT. XMAX) THEN
XMAX = RVAL(1)
ENDIF
IF (RVAL(3) .GT. XMAX) THEN
XMAX = RVAL(3)
ENDIF
IF (RVAL(2) .GT. YMAX) THEN
YMAX = RVAL(2)
ENDIF
IF (RVAL(4) .GT. YMAX) THEN
YMAX = RVAL(4)
ENDIF
ENDIF
IF (LAST) THEN
GOTO 2100
ENDIF
2090 GOTO 2080
2100 CONTINUE
100 CONTINUE
IF (ICH .GT. 32) THEN
XSIZE(ICH) = (XMAX + CHSP)/POINT
ELSE
XSIZE(ICH) = (XMAX)/POINT
ENDIF
YSIZE(ICH) = YMAX/POINT
NVECT(ICH) = NLOCVC
DO 2110 I = 48, 57
XSIZE(I) = 1.
2110 CONTINUE
XSIZE(43) = 1.
XSIZE(45) = 1.
WRITE(6, *) ' Total number of vectors in font is ', NTOTVC
WRITE(6, *) ' The most number of vectors per character is ', MAX
*VECT
WRITE(6, *) ' for character ', MAXCHR
NVECT(32) = 0
WRITE(6, *) ' Number of vectors for character 32 (blank) set to
*zero.'
WRITE(OUTFONT) NTOTVC, CHSP, POINT
WRITE(OUTFONT) (IDEX(I), I=1,200)
WRITE(OUTFONT) (NVECT(I),I=1,200)
WRITE(OUTFONT) (XSIZE(I),I=1,200)
WRITE(OUTFONT) (YSIZE(I),I=1,200)
WRITE(OUTFONT) (X0(I),I=1,NTOTVC)
WRITE(OUTFONT) (Y0(I),I=1,NTOTVC)
WRITE(OUTFONT) (X1(I),I=1,NTOTVC)
WRITE(OUTFONT) (Y1(I),I=1,NTOTVC)
2060 CONTINUE
CLOSE(INFONT)
CLOSE(OUTFONT)
STOP
20 WRITE(6, *) ' Bad format for input'
STOP
21 WRITE(6, *) 'Error in opening font file.'
END
|
#include "PILOT.inc"
SUBROUTINE SSPRT(ID)
C-----------------------------------------------------------------------
C
C Print decay modes for ID. Note these need not be contiguous,
C so the loop is over all modes in /SSMODE/.
C
C-----------------------------------------------------------------------
#ifdef IMPNONE_X
IMPLICIT NONE
#endif
#include "sslun.inc"
#include "ssmode.inc"
C
INTEGER ID,I,K,NOUT
CHARACTER*5 SSID,LBLIN,LBLOUT(4)
C
NOUT=0
DO 100 I=1,NSSMOD
IF(ISSMOD(I).NE.ID) GO TO 100
NOUT=NOUT+1
LBLIN=SSID(ISSMOD(I))
DO 110 K=1,4
110 LBLOUT(K)=SSID(JSSMOD(K,I))
WRITE(LOUT,1000) LBLIN,(LBLOUT(K),K=1,4),GSSMOD(I),BSSMOD(I)
1000 FORMAT(1X,A5,' --> ',4(A5,2X),2E15.5)
100 CONTINUE
C
IF(NOUT.GT.0) WRITE(LOUT,*) ' '
C
RETURN
END
|
FUNCTION IFXY(ADSC)
C$$$ SUBPROGRAM DOCUMENTATION BLOCK
C
C SUBPROGRAM: IFXY
C PRGMMR: WOOLLEN ORG: NP20 DATE: 1994-01-06
C
C ABSTRACT: THIS FUNCTION RETURNS THE INTEGER CORRESPONDING TO THE
C BIT-WISE REPRESENTATION OF AN INPUT CHARACTER FXY VALUE OF LENGTH
C SIX.
C
C PROGRAM HISTORY LOG:
C 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
C 2003-11-04 J. ATOR -- ADDED DOCUMENTATION
C 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
C INTERDEPENDENCIES
C 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED HISTORY
C DOCUMENTATION
C DART $Id$
C
C USAGE: IFXY (ADSC)
C INPUT ARGUMENT LIST:
C ADSC - CHARACTER*6: CHARACTER FORM OF DESCRIPTOR (FXY VALUE)
C
C OUTPUT ARGUMENT LIST:
C IFXY - INTEGER: BIT-WISE REPRESENTATION OF DESCRIPTOR (FXY)
C VALUE
C
C REMARKS:
C
C EXAMPLE:
C
C If ADSC = '063022', then IFXY = 16150 since:
C
C 0 63 22
C
C F | X | Y
C | |
C 0 0 1 1 1 1 1 1 0 0 0 1 0 1 1 0 =
C
C ( 2**13 + 2**12 + 2**11 + 2**10 +
C 2**9 + 2**8 + 2**4 + 2**2 + 2**1 ) = 16150
C
C
C THIS ROUTINE CALLS: None
C THIS ROUTINE IS CALLED BY: BFRINI DXINIT IDN30 NEMTAB
C NEMTBB NEMTBD RDBFDX RDUSDX
C RESTD UFBQCP
C Normally not called by any application
C programs but it could be.
C
C ATTRIBUTES:
C LANGUAGE: FORTRAN 77
C MACHINE: PORTABLE TO ALL PLATFORMS
C
C$$$
CHARACTER*6 ADSC
C----------------------------------------------------------------------
C----------------------------------------------------------------------
READ(ADSC,'(I1,I2,I3)') IF,IX,IY
IFXY = IF*2**14 + IX*2**8 + IY
RETURN
END
|
c QSATS version 1.0 (3 March 2011)
c file name: eloc.f
c ----------------------------------------------------------------------
c this computes the total energy and the expectation value of the
c potential energy from the snapshots recorded by QSATS.
c ----------------------------------------------------------------------
program eloc
implicit double precision (a-h, o-z)
include 'sizes.h'
include 'qsats.h'
c --- this common block is used to enable interpolation in the potential
c energy lookup table in the subroutine local below.
common /bincom/ bin, binvrs, r2min
dimension q(NATOM3), vtavg(NREPS), vtavg2(NREPS),
+ etavg(NREPS), etavg2(NREPS)
parameter (half=0.5d0)
parameter (one=1.0d0)
c --- initialization.
call tstamp
write (6, 6001) NREPS, NATOMS, NATOM3, NATOM6, NATOM7,
+ NVBINS, RATIO, NIP, NPAIRS
6001 format ('compile-time parameters:'//,
+ 'NREPS = ', i6/,
+ 'NATOMS = ', i6/,
+ 'NATOM3 = ', i6/,
+ 'NATOM6 = ', i6/,
+ 'NATOM7 = ', i6/,
+ 'NVBINS = ', i6/,
+ 'RATIO = ', f6.4/,
+ 'NIP = ', i6/,
+ 'NPAIRS = ', i6/)
call input
call vinit(r2min, bin)
binvrs=one/bin
c --- read crystal lattice points.
write (6, 6200) ltfile
6200 format ('READING crystal lattice from ', a16/)
open (8, file=ltfile, status='old')
read (8, *) nlpts
if (nlpts.ne.NATOMS) then
write (6, *) 'ERROR: number of atoms in lattice file = ', nlpts
write (6, *) 'number of atoms in source code = ', NATOMS
stop
end if
c --- read the edge lengths of the supercell.
read (8, *) xlen, ylen, zlen
c --- compute a distance scaling factor.
den0=dble(NATOMS)/(xlen*ylen*zlen)
c --- scale is a distance scaling factor, computed from the atomic
c number density specified by the user.
scale=exp(dlog(den/den0)/3.0d0)
write (6, 6300) scale
6300 format ('supercell scaling factor computed from density = ',
+ f12.8/)
xlen=xlen/scale
ylen=ylen/scale
zlen=zlen/scale
write (6, 6310) xlen, ylen, zlen
6310 format ('supercell edge lengths [bohr] = ', 3f10.5/)
dxmax=half*xlen
dymax=half*ylen
dzmax=half*zlen
do i=1, NATOMS
read (8, *) xtal(i, 1), xtal(i, 2), xtal(i, 3)
xtal(i, 1)=xtal(i, 1)/scale
xtal(i, 2)=xtal(i, 2)/scale
xtal(i, 3)=xtal(i, 3)/scale
end do
close (8)
write (6, 6320) xtal(NATOMS, 1), xtal(NATOMS, 2),
+ xtal(NATOMS, 3)
6320 format ('final lattice point [bohr] = ', 3f10.5/)
c --- this variable helps us remember the nearest-neighbor distance.
rnnmin=-1.0d0
do j=2, NATOMS
dx=xtal(j, 1)-xtal(1, 1)
dy=xtal(j, 2)-xtal(1, 2)
dz=xtal(j, 3)-xtal(1, 3)
c ------ this sequence of if-then-else statements enforces the
c minimum image convention.
if (dx.gt.dxmax) then
dx=dx-xlen
else if (dx.lt.-dxmax) then
dx=dx+xlen
end if
if (dy.gt.dymax) then
dy=dy-ylen
else if (dy.lt.-dymax) then
dy=dy+ylen
end if
if (dz.gt.dzmax) then
dz=dz-zlen
else if (dz.lt.-dzmax) then
dz=dz+zlen
end if
r=sqrt(dx*dx+dy*dy+dz*dz)
if (r.lt.rnnmin.or.rnnmin.le.0.0d0) rnnmin=r
end do
write (6, 6330) rnnmin
6330 format ('nearest neighbor (NN) distance [bohr] = ', f10.5/)
write (6, 6340) xlen/rnnmin, ylen/rnnmin, zlen/rnnmin
6340 format ('supercell edge lengths [NN distances] = ', 3f10.5/)
c --- compute interacting pairs.
do i=1, NATOMS
npair(i)=0
end do
nvpair=0
do i=1, NATOMS
do j=1, NATOMS
if (j.ne.i) then
dx=xtal(j, 1)-xtal(i, 1)
dy=xtal(j, 2)-xtal(i, 2)
dz=xtal(j, 3)-xtal(i, 3)
c --------- this sequence of if-then-else statements enforces the
c minimum image convention.
if (dx.gt.dxmax) then
dx=dx-xlen
else if (dx.lt.-dxmax) then
dx=dx+xlen
end if
if (dy.gt.dymax) then
dy=dy-ylen
else if (dy.lt.-dymax) then
dy=dy+ylen
end if
if (dz.gt.dzmax) then
dz=dz-zlen
else if (dz.lt.-dzmax) then
dz=dz+zlen
end if
r2=dx*dx+dy*dy+dz*dz
r=sqrt(r2)
c --------- interacting pairs are those for which r is less than a
c certain cutoff amount.
if (r/rnnmin.lt.RATIO) then
nvpair=nvpair+1
ivpair(1, nvpair)=i
ivpair(2, nvpair)=j
vpvec(1, nvpair)=dx
vpvec(2, nvpair)=dy
vpvec(3, nvpair)=dz
npair(i)=npair(i)+1
ipairs(npair(i), i)=nvpair
end if
end if
end do
end do
write (6, 6400) npair(1), nvpair
6400 format ('atom 1 interacts with ', i3, ' other atoms'//,
+ 'total number of interacting pairs = ', i6/)
c --- initialization.
loop=0
do k=1, NREPS
vtavg(k)=0.0d0
etavg(k)=0.0d0
vtavg2(k)=0.0d0
etavg2(k)=0.0d0
end do
open (10, file=spfile, form='unformatted')
c --- this loops reads the snapshots saved by QSATS.
300 loop=loop+1
do k=1, NREPS, 11
read (10, end=600) (path(i, k), i=1, NATOM3)
c ------ compute the local energy and the potential energy.
do i=1, NATOM3
q(i)=path(i, k)
end do
call local(q, tloc, vloc)
c ------ convert to kelvin per atom.
tloc=tloc/(3.1668513d-6*dble(NATOMS))
vloc=vloc/(3.1668513d-6*dble(NATOMS))
c ------ accumulate the results.
vtavg(k)=vtavg(k)+vloc
vtavg2(k)=vtavg2(k)+(vloc)**2
etavg(k)=etavg(k)+tloc+vloc
etavg2(k)=etavg2(k)+(tloc+vloc)**2
350 continue
end do
goto 300
c --- account for overshooting.
600 loop=loop-1
write (6, 6600) loop
6600 format ('number of snapshots = ', i6/)
c --- compute the averages and standard deviations.
do k=1, NREPS, 11
vtavg(k)=vtavg(k)/dble(loop)
vtavg2(k)=vtavg2(k)/dble(loop)
etavg(k)=etavg(k)/dble(loop)
etavg2(k)=etavg2(k)/dble(loop)
vsd=sqrt(vtavg2(k)-vtavg(k)**2)
esd=sqrt(etavg2(k)-etavg(k)**2)
write (6, 6610) k, 'VAVG = ', vtavg(k)
6610 format ('replica ', i3, 1x, a7, f10.5, ' Kelvin')
write (6, 6610) k, 'V SD = ', vsd
write (6, 6610) k, 'EAVG = ', etavg(k)
write (6, 6610) k, 'E SD = ', esd
end do
stop
end
c ----------------------------------------------------------------------
c this subroutine computes the local energy and potential energy
c of a configuration.
c ----------------------------------------------------------------------
subroutine local(q, tloc, vloc)
implicit double precision (a-h, o-z)
include 'sizes.h'
include 'qsats.h'
common /bincom/ bin, binvrs, r2min
c --- alpha is the exponential parameter in psi:
c psi = N * exp(-alpha*(r-r0)**2) * Jastrow
c --- bb is the exponential parameter in Jastrow:
c ln Jastrow(ij) = -0.5 * (bb/rij)**5
dimension q(NATOM3), dlng(NATOM3), d2lng(NATOM3)
do i=1, NATOM3
dlng(i)=0.0d0
d2lng(i)=0.0d0
end do
do i=1, NATOMS
xx=q(3*i-2)
yy=q(3*i-1)
zz=q(3*i)
dlng(3*i-2)=dlng(3*i-2)-2.0d0*aa*xx
dlng(3*i-1)=dlng(3*i-1)-2.0d0*aa*yy
dlng(3*i) =dlng(3*i) -2.0d0*aa*zz
d2lng(3*i-2)=d2lng(3*i-2)-2.0d0*aa
d2lng(3*i-1)=d2lng(3*i-1)-2.0d0*aa
d2lng(3*i) =d2lng(3*i) -2.0d0*aa
end do
c --- loop over all interacting pairs.
vloc=0.0d0
tloc=0.0d0
do n=1, nvpair
i=ivpair(1, n)
j=ivpair(2, n)
dx=-((q(3*j-2))+vpvec(1, n)+(-q(3*i-2)))
dy=-((q(3*j-1))+vpvec(2, n)+(-q(3*i-1)))
dz=-((q(3*j)) +vpvec(3, n)+(-q(3*i)) )
r2=dx*dx+dy*dy+dz*dz
ibin=int((r2-r2min)*binvrs)+1
if (ibin.gt.0) then
dr=(r2-r2min)-bin*dble(ibin-1)
vloc=vloc+v(1, ibin)+v(2, ibin)*dr
else
vloc=vloc+v(1, 1)
end if
br2=bb*bb/r2
br5=br2*br2*sqrt(br2)
br52=br5/r2
dlng(3*i-2)=dlng(3*i-2)+2.5d0*br52*dx
dlng(3*i-1)=dlng(3*i-1)+2.5d0*br52*dy
dlng(3*i) =dlng(3*i) +2.5d0*br52*dz
d2lng(3*i-2)=d2lng(3*i-2)+2.5d0*br52*
* (1.0d0-7.0d0*dx**2/r2)
d2lng(3*i-1)=d2lng(3*i-1)+2.5d0*br52*
* (1.0d0-7.0d0*dy**2/r2)
d2lng(3*i) =d2lng(3*i) +2.5d0*br52*
* (1.0d0-7.0d0*dz**2/r2)
end do
c --- now sum up the kinetic energy components.
do i=1, NATOM3
tloc=tloc+d2lng(i)+dlng(i)**2
end do
c --- account for mass factor and for double-counting of pairs.
tloc=-0.5d0*tloc/amass
vloc=0.5d0*vloc
return
end
c ----------------------------------------------------------------------
c quit is a subroutine used to terminate execution if there is
c an error.
c it is needed here because the subroutine that reads the parameters
c (subroutine input) may call it.
c ----------------------------------------------------------------------
subroutine quit
write (6, *) 'termination via subroutine quit'
stop
return
end
|
subroutine rexsph ( mphase, ipr2, ispec, vixan, xkstep, xkmax,
1 gamach, rgrd,
1 nph, lmaxph, potlbl, spinph, iatph, nat, rat, iphat,
2 ixc, vr0, vi0, ixc0, lreal, rfms2, lfms2, l2lp,
3 ipol, ispin, le2, angks, ptz, iPl, iGrid,
4 izstd, ifxc, ipmbse, itdlda, nonlocal, ibasis)
use json_module
implicit double precision (a-h, o-z)
logical :: found
type(json_file) :: json !the JSON structure read from the file:
double precision toss
integer,dimension(:),allocatable :: intgs
character*80,dimension(:),allocatable :: strings
double precision,dimension(:),allocatable :: dbpcs
include '../HEADERS/const.h'
include '../HEADERS/dim.h'
cc geom.dat
integer nat, iatph(0:nphx), iphat(natx), ibounc(natx)
double precision rat(3,natx)
cc global.dat
c configuration average
integer nabs, iphabs
c global polarization data
integer ipol, ispin, le2
double precision evec(3), xivec(3), spvec(3), elpty,angks,rclabs
complex*16 ptz(-1:1, -1:1)
cc mod2.inp
integer mphase, ipr2, ixc, ixc0, ispec, lreal, lfms2, l2lp, iPl,
& iGrid
double precision rgrd, gamach, xkstep, xkmax, vixan
double precision vr0, vi0, spinph(0:nphx)
real rfms2
integer lmaxph(0:nphx)
character*6 potlbl(0:nphx)
integer izstd, ifxc, ipmbse, itdlda, nonlocal, ibasis
c Local stuff
c character*512 slog
c character*80 head(nheadx)
c dimension lhead(nheadx)
c standard formats for string, integers and real numbers
c 10 format(a)
c 20 format (20i4)
c 30 format (6f13.5)
call json_read_geom(nat, nph, iatph, rat, iphat, ibounc)
call json_read_global(nabs, iphabs, rclabs, ipol, ispin, le2,
1 elpty, angks, evec, xivec, spvec, ptz)
call json%load_file('xsph.json')
if (json_failed()) then !if there was an error reading the file
print *, "failed to read xsph.json"
stop
else
call json%get('mphase', mphase, found)
if (.not. found) call bailout('mphase', 'xsph.json')
call json%get('ipr2', ipr2, found)
if (.not. found) call bailout('ipr2', 'xsph.json')
call json%get('ixc', ixc, found)
if (.not. found) call bailout('ixc', 'xsph.json')
call json%get('ixc0', ixc0, found)
if (.not. found) call bailout('ixc0', 'xsph.json')
call json%get('ispec', ispec, found)
if (.not. found) call bailout('ispec', 'xsph.json')
call json%get('lreal', lreal, found)
if (.not. found) call bailout('lreal', 'xsph.json')
call json%get('lfms2', lfms2, found)
if (.not. found) call bailout('lfms2', 'xsph.json')
call json%get('nph', nph, found)
if (.not. found) call bailout('nph', 'xsph.json')
call json%get('l2lp', l2lp, found)
if (.not. found) call bailout('l2lp', 'xsph.json')
call json%get('iPlsmn', iPl, found)
if (.not. found) call bailout('iPlsmn', 'xsph.json')
call json%get('iGrid', iGrid, found)
if (.not. found) call bailout('iGrid', 'xsph.json')
call json%get('vro', vr0, found)
if (.not. found) call bailout('vr0', 'xsph.json')
call json%get('vio', vi0, found)
if (.not. found) call bailout('vi0', 'xsph.json')
call json%get('rgrd', rgrd, found)
if (.not. found) call bailout('rgrd', 'xsph.json')
call json%get('rfms2', toss, found)
if (.not. found) call bailout('rfms2', 'xsph.json')
rfms2 = real(toss)
call json%get('gamach', gamach, found)
if (.not. found) call bailout('gamach', 'xsph.json')
call json%get('xkstep', xkstep, found)
if (.not. found) call bailout('xkstep', 'xsph.json')
call json%get('xkmax', xkmax, found)
if (.not. found) call bailout('xkmax', 'xsph.json')
call json%get('vixan', vixan, found)
if (.not. found) call bailout('vixan', 'xsph.json')
call json%get('izstd', izstd, found)
if (.not. found) call bailout('izstd', 'xsph.json')
call json%get('ifxc', ifxc, found)
if (.not. found) call bailout('ifxc', 'xsph.json')
call json%get('ipmbse', ipmbse, found)
if (.not. found) call bailout('ipmbse', 'xsph.json')
call json%get('itdlda', itdlda, found)
if (.not. found) call bailout('itdlda', 'xsph.json')
call json%get('nonlocal', nonlocal, found)
if (.not. found) call bailout('nonlocal', 'xsph.json')
call json%get('ibasis', ibasis, found)
if (.not. found) call bailout('ibasis', 'xsph.json')
call json%get('potlbl', strings, found)
if (.not. found) call bailout('potlbl', 'xsph.json')
do itit = 1, nphx
c potlbl(itit-1) = strings(itit)
potlbl(itit-1) = strings(itit)(1:6)
enddo
call json%get('lmaxph', intgs, found)
if (.not. found) call bailout('lmaxph', 'xsph.json')
do iph = 0, nphx
lmaxph(iph) = intgs(iph+1)
enddo
call json%get('spinph', dbpcs, found)
if (.not. found) call bailout('spinph', 'xsph.json')
do iph = 0, nphx
spinph(iph) = dbpcs(iph+1)
enddo
call json%destroy()
end if
c transform to code units (bohrs and hartrees - atomic unuts)
rfms2 = rfms2 / real(bohr)
vr0 = vr0 / hart
vi0 = vi0 / hart
gamach = gamach / hart
vixan = vixan / hart
xkstep = xkstep * bohr
xkmax = xkmax * bohr
do i = 1,3
do iat = 1, nat
rat(i,iat) = rat(i,iat) / bohr
enddo
enddo
return
end
|
c ==========================================================
c Function filter4. Broadband filreting.
c ==========================================================
c Parameters for filter4 function:
c Input parameters:
c f1,f2 - low corner frequences, f2 > f1, Hz, (double)
c f3,f4 - high corner frequences, f4 > f3, Hz, (double)
c npow - power of cosine tapering, (int)
c dt - sampling rate of seismogram in seconds, (double)
c n - number of input samples, (int)
c seis_in - input array length of n, (float)
c Output parameters:
c seis_out - output array length of n, (float)
c ==========================================================
subroutine gaufilt(alpha,c_per,dt,n,seis_in,seis_out)
implicit none
include 'fftw3.h'
integer*4 n
real*8 alpha,dt,c_per
real*4 seis_in(400000),seis_out(400000)
c ---
integer*4 k,ns,nk
real*8 plan1,plan2
real*8 dom,pi,om0
double complex czero,s(400000),sf(400000)
c ---
czero = (0.0d0,0.0d0)
c determin the power of FFT
ns = 2**max0(int(dlog(dble(n))/dlog(2.0d0))+1,13)
pi = datan(1.0d0)*4.0d0
om0 = 2.0d0*pi/c_per
dom = 2*pi/dt/ns
do k = 1,ns
s(k) = czero
enddo
do k = 1,n
s(k) = seis_in(k)
enddo
c make backward FFT for seismogram: s ==> sf
call dfftw_plan_dft_1d(plan1,ns,s,sf,
* FFTW_BACKWARD, FFTW_ESTIMATE)
call dfftw_execute(plan1)
call dfftw_destroy_plan(plan1)
c kill half spectra and correct ends
nk = ns/2+1
do k = nk+1,ns
sf(k) = czero
enddo
sf(1) = sf(1)/2.0d0
sf(nk) = dcmplx(dreal(sf(nk)),0.0d0)
c===============================================================
c make gaussian tapering
call gautap(alpha,om0,dom,nk,sf)
c===============================================================
c make forward FFT for seismogram: sf ==> s
call dfftw_plan_dft_1d(plan2,ns,sf,s,
* FFTW_FORWARD, FFTW_ESTIMATE)
call dfftw_execute(plan2)
call dfftw_destroy_plan(plan2)
c forming final result
do k = 1,n
seis_out(k) = 2.0*real(dreal(s(k)))/ns
enddo
return
end
c===============================================================
c Gaussian tapering subroutine itself
c===============================================================
subroutine gautap(alpha,om0,dom,nk,sf)
implicit none
integer*4 k, nk
real*8 alpha,om0,dom,ome,om2,b(32768)
double complex sf(32768)
do k=1,nk
b(k)=0.0d0
ome = (k-1)*dom
om2 = -(ome-om0)*(ome-om0)*alpha/om0/om0
c if( dabs(om2) .le. 40.0d0 ) then
b(k) = dexp(om2)
c if( dabs(b(k)-0.5).le.0.01) write(*,*) ome/2./3.14159264, om0/2./3.14159265
sf(k) = sf(k)*b(k)
c endif
enddo
return
end
|
DIMENSION TITL(20)
CHARACTER CSTR*80
EQUIVALENCE (CSTR,TITL)
CALL SETERM(MTRN)
OPEN(7,FILE='SIM.TMP',STATUS='UNKNOWN')
OPEN(10,FILE='SIM.PCT',STATUS='UNKNOWN')
OPEN(77,FILE='SIM.DS',STATUS='UNKNOWN')
DS=.15
E=.1
RB=.4
NT=600
VS=100000.
EM=1.76E11
STH0=.00001
CTH0=1.
VX=1.
VMXX=-1.
KS=0
1 CALL COLRX(2)
CALL HPX
WRITE(*,100) RB
100 FORMAT(' Motion of an electron in crossed E,B fields'
C,/' E is DOWN the plane of the screen and B is INTO the plane'
C,/' Velocities are in units of a "scale" velocity Vs=10**5 M/Sec'
C,/' "Q"- Quits the whole show'
C,/' "I"- Returns to these instructions'
C,/' "C"- Clears and redraws screen '
C,/' Input speed is calculated as Vs*(10K+J)'
C,/' "K,0-9"- Input "K" for speed input'
C,/' "0-9"- Input "J" for speed input'
C,/' "M"- Multiplies VS by 2 '
C,/' "D"- Divides VS by 2 '
C,/' Rb=M*Vs/(e*B) is the cyclotron radius at scale velocity'
C,/' Rb=',F8.3,' m Enter Rb ->',$)
CALL DATAF
CALL DATA1(RB,1,M)
IF(M.EQ.10) M=0
IF(M.EQ.1) GO TO 1
IF(M.NE.0) GO TO 99
IF(RB.EQ.0.) RB=.01
B=10000.*VS/EM/RB
WRITE(*,106) E
106 FORMAT(' E=',E12.4,' V/m Enter your choice ->',$)
CALL DATAF
CALL DATA1(E,1,M)
IF(M.EQ.10) M=0
IF(M.EQ.1) GO TO 1
IF(M.EQ.5) KEYIN=-1
IF(M.EQ.5) GO TO 1
IF(M.NE.0) GO TO 99
20 CALL HP
CALL TOUTPT(24)
CALL COLRX(5)
CALL TSEND
CALL PLOT(3.1,3.,-3)
WRITE(CSTR,107)
107 FORMAT(' Scale 1 In=1 Meter')
CALL SYMBOL(-2.,2.8,.1,TITL,0.,20)
CALL COLRX(6)
WRITE(CSTR,102)
102 FORMAT(' Electron motion in crossed E,B fields')
CALL SYMBOL(-2.5,2.6,.1,TITL,0.,38)
CALL COLRX(2)
WRITE(CSTR,103) E,B
103 FORMAT(' E(down)=',E11.3,' V/m B(in)=',E11.3,' Gauss')
CALL SYMBOL(-2.5,-2.7,.1,TITL,0.,49)
CALL COLOR(100)
CALL PLOT(-3.,-2.5,3)
CALL PLOT(3.,-2.5,2)
CALL PLOT(3.,2.5,2)
CALL PLOT(-3.,2.5,2)
CALL PLOT(-3.,-2.5,2)
CALL PLOT(-.1,0.,3)
CALL PLOT(.1,0.,2)
CALL PLOT(0.,-.1,3)
CALL PLOT(0.,.1,2)
CALL COLRX(6)
CALL SYMBOL(3.1,2.4,.1,'?: Instructions',0.,15)
CALL SYMBOL(3.1,2.25,.1,'I: Instructions',0.,15)
CALL SYMBOL(3.1,2.1,.1,'C: Clear, redraw',0.,16)
CALL SYMBOL(3.1,1.95,.1,'Q: Erase, Quit',0.,14)
CALL SYMBOL(3.1,1.8,.1,'M: Vs=Vs*2',0.,11)
CALL SYMBOL(3.1,1.65,.1,'D: Vs=Vs/2',0.,11)
CALL SYMBOL(3.1,1.5,.1,'B,M: B=B*2',0.,10)
CALL SYMBOL(3.1,1.35,.1,'B,D: B=B/2',0.,10)
CALL SYMBOL(3.1,1.2,.1,'B,S: B=-B',0.,9)
CALL SYMBOL(3.1,1.05,.1,'E,M: E=E*2',0.,10)
CALL SYMBOL(3.1,.90,.1,'E,D: E=E/2',0.,10)
CALL SYMBOL(3.1,.75,.1,'E,S: E=-E',0.,9)
CALL SYMBOL(3.1,.6,.1,'K,Int: K=Int',0.,12)
CALL SYMBOL(3.1,.45,.1,'Int: V=Vs*(10*K+Int)',0.,20)
WE=SQRT(ABS(EM*E/2./DS))
GO TO 10
21 UD=E/B*10000.
VP=V-UD
WC=VS/RB
RC=SQRT(V**2+UD**2-2.*V*UD*CTH0)/WC
WB=ABS(VP)/DS
IF(V.EQ.VMXX) GO TO 8
IF(VMXX.EQ.-1.) VMXX=V
CALL COLOR(0)
CALL TSEND
WRITE(CSTR,104) VMXX
CALL SYMBOL(-2.5,-2.9,.1,TITL,0.,27)
104 FORMAT(' Velocity=',E11.3,' m/sec')
CALL COLRX(ICOL)
WRITE(CSTR,104) V
CALL SYMBOL(-2.5,-2.9,.1,TITL,0.,27)
8 VMXX=V
T=V*STH0/(UD-V*CTH0+1.E-12)
T=ATAN(T)/WC
IF(STH0*SIN(WC*T).LT.0.) T=T+3.1415927/WC
X0=UD*T-RC*SIN(WC*T)
Y0=RC*(1.-COS(WC*T))
CALL PLOT(0.,0.,3)
DO 4 I=1,NT
VEL=SQRT(ABS(V**2+2.*EM*Y*E))
DT=VEL/DS+WE+WB
IF(DT.LE.0.) GO TO 10
DT=1./DT
T=T+DT
Y=RC*(1.-COS(WC*T))-Y0
X=UD*T-RC*SIN(WC*T)-X0
CALL PLOT(X,Y,2)
IF(X.GT.3.) GO TO 10
IF(X.LT.-3.) GO TO 10
IF(Y.GT.2.5) GO TO 10
IF(Y.LT.-2.5) GO TO 10
4 CONTINUE
10 CALL CURSR(IC,X,Y)
IF(IC.GT.90) IC=IC-32
11 IF(IC.EQ.81) GO TO 99
IF(IC.EQ.73) IC=63
IF(IC.EQ.67.OR.IC.EQ.63) CALL PLOT(6.,-3.,-3)
IF(IC.EQ.67.OR.IC.EQ.63) CALL PLOT(0.,0.,-3)
IF(IC.EQ.67) GO TO 20
IF(IC.EQ.63) GO TO 1
IF(IC.EQ.77) VX=VX*2.
IF(IC.EQ.77) V=V*2.
IF(IC.EQ.75) CALL CURSR(KS,X,Y)
IF(IC.EQ.75) KS=KS-48
IF(IC.EQ.75) GO TO 10
IF(IC.EQ.68) VX=VX/2.
IF(IC.EQ.68) V=V/2.
IF(IC.EQ.68.OR.IC.EQ.77) GO TO 21
IF(IC.NE.66.AND.IC.NE.69) GO TO 2
EMXX=E
BMXX=B
3 CALL CURSR(ICC,X,Y)
IF(ICC.GT.90) ICC=ICC-32
IF(IC.EQ.66.AND.ICC.EQ.77) B=2.*B
IF(IC.EQ.66.AND.ICC.EQ.68) B=B/2.
IF(IC.EQ.66.AND.ICC.EQ.83) B=-B
IF(IC.EQ.69.AND.ICC.EQ.77) E=2.*E
IF(IC.EQ.69.AND.ICC.EQ.68) E=E/2.
IF(IC.EQ.69.AND.ICC.EQ.83) E=-E
IF(ICC.EQ.77) GO TO 3
IF(ICC.EQ.68.OR.ICC.EQ.83) GO TO 3
IC=ICC
IF(B.EQ.BMXX.AND.E.EQ.EMXX) GO TO 11
RB=RB*BMXX/B
CALL COLOR(0)
WRITE(CSTR,103) EMXX,BMXX
CALL SYMBOL(-2.5,-2.7,.1,TITL,0.,49)
CALL COLRX(2)
WRITE(CSTR,103) E,B
CALL SYMBOL(-2.5,-2.7,.1,TITL,0.,49)
GO TO 11
2 IF(IC.LT.48.OR.IC.GT.59) GO TO 10
IC=IC-48
IF(IC.GT.9) IC=0
IF(KS.GT.9) KS=0
IF(KS.LT.0) KS=0
ICOL=IC
IF(IC.EQ.0) ICOL=7
CALL COLRX(ICOL)
V=10*KS+IC
V=V*VX*VS
X=X-3.1
Y=Y-3.
STH0=Y/SQRT(X**2+Y**2)
CTH0=X/SQRT(X**2+Y**2)
CALL PLOT(0.,0.,3)
CALL PLOT(CTH0,STH0,2)
X=.9*CTH0+.025*STH0
Y=.9*STH0-.025*CTH0
CALL PLOT(X,Y,2)
X=X-.05*STH0
Y=Y+.05*CTH0
CALL PLOT(X,Y,2)
CALL PLOT(CTH0,STH0,2)
GO TO 21
99 CALL HPX
STOP
END
|
subroutine potts_mag(ns,nqm1,ista,nstate)
C Copyright Bernd Berg, Jul 9 2002.
C Magnetization measurement for the Potts model.
include '../../ForLib/implicit.sta'
include '../../ForLib/constants.par'
dimension ista(ns),nstate(0:nqm1)
ltest=.true.
do iq=0,nqm1
nstate(iq)=0
end do
do is=1,ns
nstate(ista(is))=nstate(ista(is))+1
end do
return
end
|
* -*- mode: fortran -*-
*######################################################################*
* i n c l u d e f i l e *
*######################################################################*
************************************************************************
*** dsgeneric_decayingDM.h ***
*** this piece of code is needed as a separate file ***
*** the rest of the code 'includes' dsgeneric_decayingDM.h ***
c----------------------------------------------------------------------c
c author: Torsten Bringmann (torsten.bringmann@fys.uio.no) 2016
* For every model, we use the same general structure to represent the particle
* code. HOW this is implemented (i.e. which particle codes are assigned)
* is up to the model.
include 'dsparticles.h'
parameter (numpartspecies=18) ! # particles in this model (including 17 from SM)
integer kwimp
parameter (kwimp=1)
c...decay rate and channels
integer numdecch2b, numyieldch_line
integer numdecch2bmax, numyieldch_linemax
parameter (numdecch2bmax=17,numyieldch_linemax=6)
real*8 Gammatot
real*8 decBR(numdecch2bmax)
integer dec_2body(numdecch2bmax,6),yieldchannels_line(numyieldch_linemax,2)
common /decrates/ Gammatot, decBR, dec_2body, yieldchannels_line,
& numdecch2b, numyieldch_line
*** ***
******************* end of dsgeneric_decayingDM.h ****************************
|
!
! Demonstrates use of DMMGSetSNESLocal() from Fortran
!
! Note: the access to the entries of the local arrays below use the Fortran
! convention of starting at zero. However calls to MatSetValues() start at 0.
! Also note that you will have to map the i,j,k coordinates to the local PETSc ordering
! before calling MatSetValuesLocal(). Often you will find that using PETSc's default
! code for computing the Jacobian works fine and you will not need to implement
! your own FormJacobianLocal().
program ex40f90
implicit none
#include "finclude/petsc.h"
DMMG dmmg
PetscErrorCode ierr
DA da
external FormFunctionLocal
call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
call DACreate2d(PETSC_COMM_WORLD,DA_NONPERIODIC,DA_STENCIL_BOX, &
& -10,-10,PETSC_DECIDE,PETSC_DECIDE,2,1, &
& PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,da,ierr)
! Create solver object and associate it with the unknowns (on the grid)
call DMMGCreate(PETSC_COMM_WORLD,1,PETSC_NULL_OBJECT,dmmg,ierr)
call DMMGSetDM(dmmg,da,ierr)
call DADestroy(da,ierr)
call DMMGSetSNESLocal(dmmg,FormFunctionLocal, &
& PETSC_NULL_FUNCTION,0,0,ierr)
call DMMGSetFromOptions(dmmg,ierr)
! Solve the nonlinear system
!
call DMMGSolve(dmmg,ierr)
call DMMGDestroy(dmmg,ierr)
call PetscFinalize(ierr)
end
subroutine FormFunctionLocal(in,x,f,dmmg,ierr)
implicit none
DMMG dmmg
PetscInt i,j,k
DALocalInfo in(DA_LOCAL_INFO_SIZE)
PetscScalar x(in(DA_LOCAL_INFO_DOF), &
& XG_RANGE, &
& YG_RANGE)
PetscScalar f(in(DA_LOCAL_INFO_DOF), &
& X_RANGE, &
& Y_RANGE)
PetscErrorCode ierr
do i=in(DA_LOCAL_INFO_XS)+1,in(DA_LOCAL_INFO_XS)+in(DA_LOCAL_INFO_MX)
do j=in(DA_LOCAL_INFO_YS)+1,in(DA_LOCAL_INFO_YS)+in(DA_LOCAL_INFO_MY)
do k=1,in(DA_LOCAL_INFO_DOF)
f(k,i,j) = x(k,i,j)*x(k,i,j) - 2.0
CHKMEMQ
enddo
enddo
enddo
return
end
|
C DUMMY VERSION FOR AIX: NO FORTRAN ENCODE
SUBROUTINE RICON
WRITE(*,*)'WARNING: RICON CALLED'
WRITE(*,*)'NOT IMPLEMENTED YET ON IBM/AIX'
RETURN
END
|
!-----------------------
! madgraph - a Feynman Diagram package by Tim Stelzer and Bill Long
! (c) 1993
!
! Filename: readproc.f
!-----------------------
subroutine readproc(more)
!************************************************************************
! Super-Routine that checks for duplicates
!************************************************************************
implicit none
logical more
logical DupProcess
external DupProcess
integer i
!-----------
! Begin Code
!-----------
i = 1
call readproc_1(more)
do while (dupProcess(i) .and. more)
i=i+1
call readproc_1(more)
enddo
end
subroutine readproc_1(more)
!************************************************************************
! Reads character string and converts to the appropriate process
!************************************************************************
implicit none
! Constants
include 'params.inc'
c
c quarkonium stuff
include 'onia.inc'
c integer maxlines
c parameter (maxlines=8)
c integer max_particles
c parameter (max_particles=2**7-1)
c integer max_coup
c parameter (max_coup=5)
c integer max_string
c parameter (max_string=120)
! Arguments
logical more
! Local Variables
character*(max_string) process,process_temp
character*(max_string) attempt
character*(max_string) uproc
character*10 snum
character*4 str1
character*(max_string) dirstr
integer i,nparticles,j,imin,ifinal,jj,jstop
integer nchar,length
integer k,l,nexc,nlen,kinverse
cfax
logical foundmatch,done_reading
! Global Variables
integer iline(-maxlines:maxlines),idir(-maxlines:maxlines)
integer this_coup(max_coup) ,goal_coup(max_coup)
common/to_proc/iline,idir,this_coup,goal_coup
integer nincoming,nincfirst
common/to_proc2/nincoming,nincfirst
! data nincfirst/0/
character*25 name
integer iname
common/to_name/iname,name
character*60 proc
integer iproc
common/to_write/iproc,proc
character*(4*max_particles) particle(4)
integer charge_c(max_particles)
integer iparticle(0:max_particles,0:4),inverse(max_particles)
common/to_model/iparticle, particle, inverse, charge_c
character*(max_string) iwave(max_particles),owave(max_particles)
character*(8) str2(3,max_particles)
integer info_p(5,max_particles),iposx(3,max_particles)
common/to_external/iwave,owave,iposx,info_p,str2
integer req_part(0:max_particles),exc_part(0:max_particles)
integer nores_part(0:max_particles)
common/to_filter/req_part,exc_part,nores_part
logical lwrite
common/to_multiproc/ lwrite
logical jetloop
common/to_jetloop/jetloop
integer gopt !Speed optimization setting
logical pmatch
common/to_gmatch/gopt, pmatch
logical cross_opt
common /to_crossopt/ cross_opt
integer ndcmax
parameter(ndcmax=20)
integer ndcpart,idcid(ndcmax),idcgroup(ndcmax)
logical dcfinal(ndcmax)
common/to_dc/ndcpart,idcid,idcgroup,dcfinal
c character*1 nameprefix
integer nameprefix
common/to_multiname/nameprefix
data snum /'0123456789'/
! data jetloop /.false./
! data gopt/0/
data S_qn,L_qn,J_qn,C_qn/4*0/
data onium/.false./
data em_decay/.false./
data onium_ID/"????????"/
save process_temp
!-----------
! Begin Code
!-----------
1 iname=0
if (jetloop) call inc_jet(iline(0),jetloop)
if (.not. jetloop) then
c call resetV
write(*,*)'Standard Model particles include:'
write(*,*)' Quarks: d u s c b t d~ u~ s~ c~ b~ t~'
write(*,*)
$ ' Leptons: e- mu- ta- e+ mu+ ta+ ve vm vt ve~ vm~ vt~'
write(*,*)' Bosons: g a z w+ w- h'
write(*,*)' '
write(*,*) 'Enter process you would like calculated ',
& 'in the form e+ e- -> a.'
write(*,*) '("done" to exit MadGraph.)'
process = ' '
cfax
10 read (*,'(a)',end=11,err=11), process
if(process(1:1).eq. "#".or.len_trim(process).le.1) goto 10
ctjs 5-03-06
uproc = process
call upper_case(uproc)
11 if (index(uproc,'DONE') .gt. 0) then
c 11 if (process(1:1) .eq. ' ') then
more = .false.
return
else
more = .true.
end if
!
! Ignore characters following ! and #
!
i = index(process,'!')
if (i .gt. 0) then
process = process(1:i)
endif
cfax
i = index(process,'#')
if (i .gt. 0) then
process = process(1:i-1)
endif
!
! Extract the information on the quarkonium state if it is there,
! and then take it out from the process string.
!
cfax
c-find the parenthesis
i = index(process,'[')
j = index(process,']')
if (i.gt.0 .and. j.gt.i) then
c-reset the values to zero
S_qn=0 !spin
L_qn=0 !orbital momentum
J_qn=0 !total momentum
C_qn=0 !color
onium_ID(1:8)="????????"
process_temp=uproc(i:j)
call no_spaces(process_temp,length)
if (length.ge.6) then
read (process_temp(2:2),'(i1)') S_qn
S_qn=(S_qn-1)/2
if(process_temp(3:3).eq.'S') then
L_qn=0
elseif(process_temp(3:3).eq.'P') then
L_qn=1
endif
read (process_temp(4:4),'(i1)') J_qn
read (process_temp(5:5),'(i1)') C_qn
onium_ID(17-length:8)=process_temp(8:length-1)
if(17-length.gt.1) then
do k=1,16-length
onium_ID(k:k)=" "
enddo
endif
endif
onium=.true.
if(process_temp(6:6).eq.'d') em_decay=.true.
write (*,*) " Found projection over spin and color"
write (*,*) process_temp(1:length)," : ",
& "S =",S_qn,", L =",L_qn,", J =",J_qn,", C =",C_qn,
& ", onium ID ",onium_ID
write(*,*) 'iproc',iproc
c
c-- take the [ ] out from the proc string
do k=j+1,max_string
process(k-(j-i+1):k-(j-i+1))=process(k:k)
enddo
endif
!
! Set prefix for directory name
!
cfax
i = index(process,'@')
nameprefix = 0
if (i .gt. 0) then
c namePrefix=process(i+1:i+1)
read(process(i+1:),*,err=12) nameprefix
12 process = process(1:i)
endif
!
! Parse string for particles
!
i = index(process,'>')
call getparticle(process(1:i),iline(1),nincoming)
if(nincfirst.eq.0) nincfirst=nincoming
j = index(process(i+1:),'/')+i !Break for excluded particles
jj = index(process(i+1:),'$')+i !Break for excluded resonances
jstop = len_trim(process)
c
c Allow user to specify excluded particles uu~ > w+w-bb~ / t a
c
if (jj.gt.j) jstop = jj-1
exc_part(0) = 0
if (j.gt. i) then
call getparticle(process(j+1:jstop),exc_part(1),exc_part(0))
if (exc_part(0) .gt. max_particles) then
write(*,*) 'Too many particles to exclude'
endif
c write(*,*) "Found excluded particles",exc_part(0),
c $ exc_part(1), exc_part(2)
c
c Now make sure inverse of the particle is also excluded
c
nexc = exc_part(0)
do k=1,exc_part(0)
kinverse = inverse(exc_part(k))
foundmatch = .false.
do l=1,nexc
if (kinverse .eq. exc_part(l)) then
foundmatch=.true.
endif
enddo
if (.not. foundmatch) then
if (nexc .lt. max_particles) then
nexc = nexc+1
exc_part(nexc) = kinverse
call part_string(kinverse,str1,nlen)
c write(*,*) 'Adding exclusion of ',str1
else
call part_string(kinverse,str1,nlen)
write(*,*) 'Exceeded number of exclusions',
$ ' can not exclude inverse of ',str1
endif
endif
enddo
exc_part(0)=nexc
c write(*,*) 'Excluding particles',exc_part(0),exc_part(1),
c $ exc_part(2)
c
c Now make sure CC of the particle is also excluded
c
nexc = exc_part(0)
do k=1,exc_part(0)
kinverse = charge_c(exc_part(k))
foundmatch = .false.
do l=1,nexc
if (kinverse .eq. exc_part(l)) then
foundmatch=.true.
endif
enddo
if (.not. foundmatch) then
if (nexc .lt. max_particles) then
nexc = nexc+1
exc_part(nexc) = kinverse
call part_string(exc_part(k),str1,nlen)
c write(*,*) 'Adding exclusion of CC ',str1
else
call part_string(exc_part(k),str1,nlen)
write(*,*) 'Exceeded number of exclusions ',
$ 'can not exclude cc of ',str1
endif
endif
enddo
exc_part(0)=nexc
c write(*,*) 'Excluding particles',exc_part(0),exc_part(1),
c $ exc_part(2)
endif
c
c Allow user to specify excluded s-channel particles
c uu~ > w+w-bb~ $ t a
c
nores_part(0)=0
cross_opt = .true. !If no particles required/excluded, use cross_opt
jstop = len_trim(process)
if (j.gt.jj) jstop = j-1
if (jj .gt. i) then
call getparticle(process(jj:jstop),
$ nores_part(1),nores_part(0))
c
c If excluding s-channel particles, can't use crossing optimization
c since it changes particles for s to t channel
c
if (nores_part(0) .gt. 0) then
cross_opt = .false.
write(*,*) 'Excluding s-channel particles',nores_part(0)
endif
if(j.gt.i) then
jstop=min(j,jj)
else
jstop=jj
endif
endif
c
c Check for presence of decay chain processes (specified using '(' and ')')
c
if(index(process(i+1:jstop),'(').ne.0) then
call read_dc(process(i+1:jstop),
& iline(nincoming+1),nparticles)
req_part(0)=0
c exc_part(0) = 0
cross_opt = .false. !s-channels required, so can't use crossing
else
c
c Allow user to specify intermediate particles
c uu~ > tt~ > w+w-bb~
c
j = index(process(i+1:),'>')+i !Break for required particles
req_part(0)=0
if (j .gt. i) then
call getparticle(process(i+1:j),req_part(1),req_part(0))
i = j
c
c If requiring s-channel particles, can't use crossing optimization
c since it changes particles for s to t channel
c
if (req_part(0) .gt. 0) then
cross_opt = .false.
endif
c write(*,*) 'Requiring particles',req_part(0)
endif
c
c Now get final state
c
call read_dc(process(i+1:jstop),iline(nincoming+1),nparticles)
endif
nparticles = nparticles+nincoming
iline(0) = nparticles
call set_jet(iline(0),jetloop)
j = 21
attempt = 'Attempting Process: '
do i=1,iline(0)
call part_string(iline(i),attempt(j:j+3),nchar)
j = j+nchar+1
if (i .eq. nincoming) then
attempt(j:j+2) = '-> '
j = j+3
endif
enddo
write (*,'(1x,a)') attempt(1:j)
iproc = j-18
proc = attempt(19:j)
C Set new particle ids in decay chain info
ifinal=nincoming
do i = 1, ndcpart
if(dcfinal(i)) then
ifinal = ifinal+1
if(ifinal.le.nparticles) then
print *,'Setting particle ',i,idcid(i),
$ ' to id ',iline(ifinal)
idcid(i) = iline(ifinal)
endif
endif
enddo
if (nparticles .le. 0) then
write(*,*)'No process specified. Try again'
goto 1
c more = .false.
c return
endif
if (iline(0) .lt. 3) then
write(*,'(a)') 'Sorry you must enter at least 3 particles.'
write(*,'(a,i2,a)') 'Only',iline(0),' particles found.'
write(*,'(a)') 'Please try again. '
goto 1
more = .true.
return
elseif(iline(0) .gt. maxlines-1) then
write(*,'(2a,i2,a)')
& 'Sorry this version of MadGraph configured',
& ' to a maximum of ',maxlines-1, ' external particles.'
write(*,'(i2,a)') iline(0),' particles found.'
write(*,'(a)') 'Please try again. '
goto 1
more = .false.
return
endif
c write(*,*)
c write(*,*) 'Flipping now'
c write(*,*)
do i=1,iline(0)
if (i .le. nincoming) then
iline(i)=inverse(iline(i))
c if (info_p(2,iline(i)).eq.-2) iline(i)=inverse(iline(i))
endif
enddo
!
! Determine Order in QCD, QED, QFD and Ghosts
!
call get_order
else
c call inc_jet(iline(0),jetloop) !Already called
j = 21
attempt = 'Attempting Process: '
do i=1,iline(0)
if (i .le. nincoming) iline(i)=inverse(iline(i))
call part_string(iline(i),attempt(j:j+3),nchar)
if (i .le. nincoming) iline(i)=inverse(iline(i))
j = j+nchar+1
if (i .eq. nincoming) then
attempt(j:j+2) = '-> '
j = j+3
endif
enddo
write (*,'(1x/a)') attempt(1:j)
iproc = j-18
proc = attempt(19:j)
endif
!
! make name for process
!
iname = 0
do i=1,iline(0)
if (iname .gt. 24) then
write(*,*)'name too large, truncating: ',name
iname=24
c stop
endif
if (i .eq. nincoming+1 .and. i .gt. 1) then
if (iname .lt. 24) then
iname=iname+1
name(iname:iname)='_'
endif
endif
if (i .le. nincoming) then
call part_string(inverse(iline(i)),str1,length)
else
call part_string(iline(i),str1,length)
endif
if (iname+length .gt. 24) then
write(*,*) 'Truncating name.'
length=24-iname
endif
if (length .gt. 0) name(iname+1:iname+length) = str1(1:length)
iname = iname+length
enddo
do i=1,iname
if(name(i:i) .eq. '~') name(i:i) = 'x'
c if(name(i:i) .eq. '+') name(i:i) = 'p'
c if(name(i:i) .eq. '-') name(i:i) = 'm'
enddo
c
c We'll store this for setting up the directory
c
if (lwrite) then !Haven't saved a process yet
open(unit=itnum ,file='dname.mg',status='unknown')
if (onium) then
write(dirstr,*) 'DIRNAME=P',nameprefix,'_',name(1:iname),
& process_temp(2:5)
else
write(dirstr,*) 'DIRNAME=P',nameprefix,'_',name(1:iname)
endif
call trimspace(dirstr,max_string)
write(itnum,*) dirstr(1:len_trim(dirstr))
close(itnum)
endif
c
c Now reset the default name to be matrix
c
iname=6
name='matrix'
!
! Query name for process
!
if (.not. jetloop) then
write(*,'(a,a,a)') 'Enter a name to identify process (',
& name(1:iname),'): '
cfax
c read(*,'(a)') process
process='matrix'
i=1
do while (i .lt. 75 .and. (ichar(process(i:i)) .lt. 65 .or.
& ichar(process(i:i)) .gt. 122 .or.
& (ichar(process(i:i)) .gt. 90 .and.
& ichar(process(i:i)) .lt. 97)))
i=i+1
enddo
imin = i
do while (i .lt. 75 .and. process(i:i) .ne.' ')
i=i+1
enddo
if (imin .ne. i) then
if (i-imin .gt. 14) then
write(*,*)'Truncating name'
i=imin+14
endif
iname=i-imin
name(1:iname)=process(imin:i)
endif
else
iname=6
name='matrix'
do i=1,iline(0)
if (i .le. nincoming) then
c iline(i)=inverse(iline(i))
c if (info_p(2,iline(i)).eq.-2) iline(i)=inverse(iline(i))
endif
enddo
endif
c write(*,'(a,10i5)') 'Particle codes',(iline(j),j=1,iline(0))
c if (.not. lwrite .and. .not. jetloop) then
c logic = qmatch_check(iline(0))
c endif
if (jetloop .or. gopt .eq. 1) then
gopt=1
else
gopt=2
endif
end
subroutine write_cross(lun)
c*****************************************************************************
c Write out subprocess and all non identical crossings into
c file for later input by MadGraph
c
c Careful this code doesn't work for eP->jjj yet. Only pp->jjj
c
c*****************************************************************************
implicit none
!Constants
include 'params.inc'
integer maxpcross
parameter (maxpcross = 100)
! Arguments
integer lun
! Local
integer i,j,k,ncross
integer imatch(2,maxpcross), jline(maxlines)
integer icount(2), inc_jet
logical good, moved, filled(2)
! Global
integer nincoming,nincfirst
common/to_proc2/nincoming,nincfirst
integer iline(-maxlines:maxlines),idir(-maxlines:maxlines)
integer this_coup(max_coup) ,goal_coup(max_coup)
common/to_proc/iline,idir,this_coup,goal_coup
integer icode(npartons),njet,ijet(10),kcount(10)
common /to_jets/icode, njet,ijet, kcount
!-----------
! Begin Code
!-----------
inc_jet=0
do i=1,njet
if (ijet(i) .le. nincoming) inc_jet=inc_jet+1
enddo
if (inc_jet .gt. 2) then
write(*,*) 'Crossing only works for up to 2 incoming partons'
endif
if (inc_jet .lt. 1) return
write(*,*) 'Looking for crossings',nincoming,inc_jet,njet
c
c Store original parton assignments in jline
c
do j=1,iline(0)
jline(j)=iline(j)
enddo
c
c Assume that the first ordering has been calculated or
c already written
c
ncross = 1
do i=1,inc_jet
imatch(i,ncross)= jline(ijet(i))
icount(i) = 1
enddo
c*******************************************************************
c Now start looping through all combinations
c*******************************************************************
do while (icount(1) .le. njet)
c
c Usually falls right through this and increments i=nincoming
c
i = inc_jet
do while (icount(i) .eq. njet .and. i .gt. 1)
i=i-1
enddo
c
c Increment the appropriate incoming parton
c
icount(i)=icount(i)+1
c
c Reset all "lower" partons
c
do j=i+1,inc_jet
icount(j)=1
enddo
c
c Check that this is an OK choice
c
good = .true.
if (icount(1) .gt. njet) good=.false.
if (inc_jet .ge. 2) then
if (icount(1) .eq. icount(2)) good=.false.
endif
i=0
c write(*,*) icount(1),icount(2),good
do while (good .and. i .lt. ncross)
i = i+1
good = .false.
do j=1,inc_jet
if (jline(ijet(icount(j))).ne.imatch(j,i)) good=.true.
enddo
enddo
if (good) then
c write(*,*) 'Cross',ncross+1,(ijet(icount(j)),j=1,inc_jet)
c
c Fill in the initial state
c
do j=1,inc_jet
filled(j)=.false.
enddo
do j=1,inc_jet
i = ijet(icount(j))
iline(ijet(j))=jline(i)
if (icount(j) .le. inc_jet) then
filled(icount(j))=.true.
endif
enddo
c
c Fill up the final state
c
do j=inc_jet+1,njet
moved = .false.
do i=1,inc_jet
if (j .eq. icount(i)) moved=.true.
enddo
if (moved) then
k =1
do while ( filled(k) .and. (k .lt. inc_jet))
k=k+1
enddo
iline(ijet(j)) = jline(ijet(k))
filled(k)=.true.
c write(*,*) 'Placing',ijet(k),' in ',ijet(j)
else
iline(ijet(j)) = jline(ijet(j))
endif
enddo
c call write_proc(lun)
c call write_proc(6)
c write(*,*) '****************** Ordered ************'
call order_jets(iline(0))
call write_proc(lun)
if (ncross .ge. maxpcross) then
write(*,*) 'Too many crossings in readproc.f',maxpcross
write(*,*) 'May get duplicate crossings'
else
ncross = ncross+1
do j=1,inc_jet
imatch(j,ncross)= iline(ijet(j))
enddo
endif
c
c restore original parton assignments to iline
c
do j=1,iline(0)
iline(j)=jline(j)
enddo
endif
enddo
end
subroutine write_proc(lun)
c*****************************************************************************
c Write out subprocess into file which can later be read as input
c*****************************************************************************
implicit none
!Constants
include 'params.inc'
! Arguments
integer lun
! Local
integer i,j,k, nchar
character*(max_string) attempt
character*(max_string) info_proj
character*1 lstring
integer idum,length
! External
logical DupProcess
external dupprocess
! Global
integer nincoming,nincfirst
common/to_proc2/nincoming,nincfirst
integer req_part(0:max_particles),exc_part(0:max_particles)
integer nores_part(0:max_particles)
common/to_filter/req_part,exc_part,nores_part
integer iline(-maxlines:maxlines),idir(-maxlines:maxlines)
integer this_coup(max_coup) ,goal_coup(max_coup)
common/to_proc/iline,idir,this_coup,goal_coup
character*(10) coup_name(max_coup)
integer ncoups
common/to_couplings/ncoups,coup_name
character*(4*max_particles) particle(4)
integer charge_c(max_particles)
integer iparticle(0:max_particles,0:4),inverse(max_particles)
common/to_model/iparticle, particle, inverse, charge_c
c character*1 nameprefix
integer nameprefix
common/to_multiname/nameprefix
integer ndcmax
parameter(ndcmax=20)
integer ndcpart,idcid(ndcmax),idcgroup(ndcmax)
logical dcfinal(ndcmax)
common/to_dc/ndcpart,idcid,idcgroup,dcfinal
include 'onia.inc'
! Data
!-----------
! Begin Code
!-----------
c if (DupProcess(idum)) return !Check if already did this process
j=1
attempt=""
do i=1,iline(0)
if (i .le. nincoming) then
call part_string(inverse(iline(i)),attempt(j:j+3),nchar)
else if(ndcpart.gt.0)then
c
c Print out decay chain process using write_dc
c Here one should of course replace idcid with the actual ids
c
c call part_string(iline(i),attempt(j:j+3),nchar)
call write_dc(attempt,j,idcid,ndcpart)
j=j+1
goto 5
else
call part_string(iline(i),attempt(j:j+3),nchar)
endif
j = j+nchar+1
if (i .eq. nincoming) then
attempt(j:j+2) = '-> '
j = j+3
if (req_part(0) .gt. 0) then
do k=1,req_part(0)
call part_string(req_part(k),attempt(j:j+3),nchar)
j=j+nchar+1
enddo
attempt(j:j+2) = '-> '
j = j+3
endif
endif
enddo
5 continue
if(nores_part(0) .gt. 0)then
attempt(j:j+2)='$'
j=j+3
do k=1,nores_part(0)
call part_string(nores_part(k),attempt(j:j+3),nchar)
j=j+nchar+1
enddo
endif
if (exc_part(0) .gt. 0) then
attempt(j:j+2) = ' / '
j = j+3
do k=1,exc_part(0)
call part_string(exc_part(k),attempt(j:j+3),nchar)
c
c Note we have included inverse and cc, if they don't have
c characters representations, don't include them in output
c
if (attempt(j:j) .ne. "?") then
j=j+nchar+1
endif
enddo
endif
cfax 20.08.2007
c
c add the information on the onia stuff if there
c
if(C_qn.gt.0) then
if(L_qn.eq.0) lstring='S'
if(L_qn.eq.1) lstring='P'
write (info_proj,'(a1,i1,a1,i1,i1,a2,a8,a1)')
& '[',2*S_qn+1,lstring,J_qn,C_qn,'to',onium_ID,']'
call no_spaces(info_proj,length)
attempt(j:j+length-1)=info_proj(1:length)
j=j+length
c if(em_decay) then
c attempt(j:j+4)='>l+l-'
c j=j+5
c endif
endif
c
c add prefix for directory name
c
attempt(j:j+1) =" @"
j=j+2
write(attempt(j:),*) nameprefix,'_'
j=len_trim(attempt)
write (lun,'(a)') attempt(1:j)
write (*,'(a)') 'Wrote process: ',attempt(1:j)
c write(*,*) 'Number excluded ', attempt(1:j-1)
c
c Now write out the couplings
c
do i=1,ncoups
write(lun,'(a,a,i4)') coup_name(i),'=',goal_coup(i)
enddo
cfax 12.05.2006
write (lun,'(a)') 'end_coup'
c write(lun,*)
end
logical function qmatch_check(iline)
c***********************************************************************
c Does a quick check to see if this process could match the one
c in memory, based on boson vs fermion vs anti_fermion
c***********************************************************************
implicit none
!Constants
include 'params.inc'
! Arguments
integer iline(0:10)
! Local
integer i,j,k
! Global
integer matchline(0:maxlines)
common/to_qmatch/matchline
character*(max_string) iwave(max_particles),owave(max_particles)
character*(8) str2(3,max_particles)
integer info_p(5,max_particles),iposx(3,max_particles)
common/to_external/iwave,owave,iposx,info_p,str2
character*(4*max_particles) particle(4)
integer charge_c(max_particles)
integer iparticle(0:max_particles,0:4),inverse(max_particles)
common/to_model/iparticle, particle, inverse, charge_c
!-----------
! Begin Code
!-----------
i = 0
qmatch_check=(iline(i) .eq. matchline(i)) !Same # of particles
do while (qmatch_check .and. i .lt. iline(0))
i=i+1
if (info_p(3,iline(i)) .ne. info_p(3,matchline(i))) then
qmatch_check=.false.
elseif (info_p(3,iline(i)) .eq. 1) then !This is fermion
j =inverse(iline(i))-iline(i) !make sure both are
k =inverse(matchline(i))-matchline(i) !fermion or anti
if (k * j * (k-j) .ne. 0) qmatch_check=.false.
endif
c
c New check tjs 2-12-08 check same color structure
c
if (info_p(1,iline(i)) .ne. info_p(1,matchline(i))) then
qmatch_check=.false.
endif
c
c New check by tjs 12-14-06 for case of external scalars
c
c print *,'Checking string ',str2(2,iline(i)),' against ',
c $ str2(2,matchline(i))
if (str2(2,iline(i)) .ne. str2(2,matchline(i))) then
qmatch_check=.false. !Require same mass
c print *,'False!'
c else
c print *,'True!'
endif
enddo
c if (qmatch_check) then
c write(*,*) 'Matched'
c else
c write(*,*) 'No Match'
c endif
end
Subroutine order_jets(iline)
c***********************************************************************
c Permutes the final state jets so they are in a specific order
c This should maximize chances for finding "identical" subprocess
c Orders particles according to association with the initial state,
c and then according to # in final state.
c
c Assumes that icount has all of the jets, and the ordering of
c partons placed into a jet is
c call getparticle('d d~ u u~ s s~ c c~ b b~ g',icode,i)
c***********************************************************************
implicit none
!Constants
include 'params.inc'
! Arguments
integer iline(0:maxlines)
! Local
integer i,j,nl
integer ip, inc_jet, iqmax, imax
integer nqcount(npartons)
integer iqplace(npartons)
integer jline(0:maxlines)
integer icount(10)
! Global
integer icode(npartons),njet,ijet(10),jcount(10)
common /to_jets/icode, njet,ijet, jcount
integer nincoming,nincfirst
common/to_proc2/nincoming,nincfirst
! Data
!-----------
! Begin Code
!-----------
c
c Need to set up icount according to this crossing
c
do i=1,njet
ip = iline(ijet(i))
j = 1
do while (j .le. npartons .and. icode(j) .ne. ip)
j=j+1
enddo
if (j .gt. npartons) then
write(*,*) 'Error no match',i,ijet(i),iline(ijet(i))
j = npartons
endif
icount(i)=j
enddo
c
c Start by determining the number of each parton type.
c
c write(*,'(a,8i4)') 'icount',(icount(i),i=1,njet)
c write(*,'(a,8i4)') 'icode',(icode(icount(i)),i=1,njet)
do i=1,npartons
nqcount(i)=0
iqplace(i)=0
enddo
do i=1,njet
nqcount(icount(i))=nqcount(icount(i))+1
enddo
c
c First order according to incoming partons
c
ip = 1
i=1
inc_jet = 0
do while (i .le. njet .and. ijet(i) .le. nincoming)
inc_jet=i
c write(*,*) 'Checking initial ',i,icount(i),iqplace(icount(i))
if (iqplace(icount(i)) .eq. 0) then
if (icount(i) .eq. npartons) then !Gluon
c iqplace(icount(i))=ip !Gluons always at end
c ip=ip+1
else !Quarks
c write(*,*) 'Writing iqplace initial',icount(i),ip
if (mod(icount(i),2) .eq. 1) then !Quark
c write(*,*) 'Filling',icount(i),ip
iqplace(icount(i)) = ip
ip = ip + 1
c write(*,*) 'Filling',icount(i)+1,ip
iqplace(icount(i)+1)= ip
ip = ip + 1
else !AntiQuark
c Below sets antiquark first
c iqplace(icount(i)) = ip
c ip = ip + 1
c iqplace(icount(i)-1)= ip
c ip = ip + 1
c Below is for quark always first
c write(*,*) 'Filling',icount(i)-1,ip
iqplace(icount(i)-1) = ip
ip = ip + 1
c write(*,*) 'Filling',icount(i),ip
iqplace(icount(i))= ip
ip = ip + 1
endif
endif
endif
i=i+1
enddo
c write(*,'(a,11i5)') 'iqplace',(iqplace(i),i=1,npartons)
c
c Next order by number of qq pairs alway q first, then qbar
c
iqmax = 1
do while (iqmax .gt. 0)
iqmax=0
imax = 0
do i=1,(npartons-1)/2 !Just sum over quarks, gluons at end
if (iqplace((2*i)) .eq. 0) then !Hasn't been set yet
if (nqcount(2*i -1)+nqcount(2*i) .gt. iqmax) then !New maximum
iqmax = nqcount(2*i -1)+nqcount(2*i)
imax = i
endif
endif
enddo
if (iqmax .gt. 0) then
c write(*,*) 'Writing iqplace final',i,iqmax,2*imax
iqplace((2*imax - 1)) = ip
iqplace((2*imax)) = ip+1
ip = ip+2
else
if (iqplace(npartons) .eq. 0) then
c write(*,*) 'Writing iqplace end',ip,npartons
iqplace(npartons) = ip
endif
endif
enddo
c
c Now set the final state jets in the appropriate order
c This is a bit inefficient, but should be OK
c
c write(*,*) 'Ordering',iline(0), inc_jet, njet,ip
c write(*,'(a,11i5)') 'iqplace',(iqplace(i),i=1,npartons)
c write(*,'(a,11i5)') 'icount',(icount(i),i=1,njet)
nl = inc_jet+1
do i=1,ip
do j=inc_jet+1,njet
c write(*,*) 'Checking',i,j,icount(j),iqplace(icount(j))
if (iqplace(icount(j)) .eq. i) then
jline(ijet(nl))= icode(icount(j))
c write(*,*)'Ordered',j,ijet(nl),icount(j),icode(icount(j))
nl = nl+1
endif
enddo
enddo
do i=inc_jet+1,njet
iline(ijet(i))=jline(ijet(i))
enddo
end
Subroutine set_jet_old(iline,jetloop)
c***********************************************************************
c Looks to see if any of the partons are labeled 'jet' or 'proton'
c in which case it will be necessary to loop over all the different
c partons.
c***********************************************************************
implicit none
!Constants
include 'params.inc'
! Arguments
integer iline(0:10)
logical jetloop
! Local
integer i,pcode,jcode
logical first_time
! Global
integer icode(npartons),njet,ijet(10),icount(10)
common /to_jets/icode, njet,ijet, icount
logical lwp,lwm,lz,decay,cross
common/to_decay/lwp,lwm,lz,decay,cross
character*(4*max_particles) particle(4)
integer charge_c(max_particles)
integer iparticle(0:max_particles,0:4),inverse(max_particles)
common/to_model/iparticle, particle, inverse, charge_c
integer nincoming,nincfirst
common/to_proc2/nincoming,nincfirst
! Data
Data first_time/.true./
save pcode,jcode
!-----------
! Begin Code
!-----------
njet = 0
if (first_time) then
first_time=.false.
call getparticle('P ',pcode,i)
if (i .ne. 1) then
write(*,*)'Warning no particle code for P, proton',i
pcode=-999
endif
call getparticle('J ',jcode,i)
if (i .ne. 1) then
write(*,*)'Warning no particle code for J, jet',i
jcode=-999
endif
endif
call getparticle('d d~ u u~ s s~ c c~ g',icode,i)
c call getparticle('d u s c b d~ u~ s~ c~ b~ g',icode,i)
c call getparticle('dsucbd~s~u~c~b~g',icode,i)
if (i .ne. npartons) then
write(*,*)'Warning not enough jet particle codes',i
endif
jetloop = .false.
do i=1,iline(0)
if (iline(i) .eq. pcode .or. iline(i) .eq. jcode .or.
$ inverse(iline(i)) .eq. pcode) then
jetloop = .true.
njet = njet+1
iline(i) = icode(1)
if (i .le. nincoming) iline(i)=inverse(iline(i))
ijet(njet) = i
icount(njet) = 1
endif
enddo
if (ijet(1) .eq. 1 .and. ijet(2) .eq. 2) then
cross=.true.
cross=.false.
else
cross=.false.
endif
end
Subroutine set_jet(iline,jetloop)
c***********************************************************************
c Looks to see if any of the partons are labeled 'jet' or 'proton'
c in which case it will be necessary to loop over all the different
c partons.
c***********************************************************************
implicit none
!Constants
include 'params.inc'
! Arguments
integer iline(0:10)
logical jetloop
! Local
integer i,j
character*(5) str1
! Global
integer SumParticles(0:maxpartons,0:maxloops)
integer icount(maxpartons,maxloops)
integer njets(0:maxpartons)
integer ijet(maxpartons,maxloops)
common/to_SumParticles/ SumParticles,icount,ijet,njets
integer nincoming,nincfirst
common/to_proc2/nincoming,nincfirst
character*(4*max_particles) particle(4)
integer charge_c(max_particles)
integer iparticle(0:max_particles,0:4),inverse(max_particles)
common/to_model/iparticle, particle, inverse, charge_c
logical cross_opt
common /to_crossopt/ cross_opt
!-----------
! Begin Code
!-----------
cross_opt = .false.
do i=1,SumParticles(0,0)
njets(i) = 0
enddo
jetloop = .false.
do i=1,iline(0)
do j=1,SumParticles(0,0)
if (iline(i) .eq. SumParticles(0,j)) then
c write(*,*) 'Found jet loop',i,j
c read(*,*) str1
jetloop = .true.
njets(j) = njets(j)+1
iline(i) = SumParticles(2,j)
if (i .le. nincoming) iline(i)=inverse(iline(i))
ijet(njets(j),j) = i
icount(njets(j),j) = 1
endif
enddo
enddo
end
Subroutine inc_jet(iline,jetloop)
c***********************************************************************
c Loops over the different possible partons in protons and jets
c***********************************************************************
implicit none
!Constants
include 'params.inc'
c integer npartons
c parameter (npartons=11)
! Arguments
integer iline(0:10)
logical jetloop
! Local
logical possible, foundone
integer i,j,kloop,iloop,nf(-1:1)
integer iexternal
! Global
integer SumParticles(0:maxpartons,0:maxloops)
integer icount(maxpartons,maxloops)
integer njets(0:maxpartons)
integer ijet(maxpartons,maxloops)
common/to_SumParticles/ SumParticles,icount,ijet,njets
character*(max_string) iwave(max_particles),owave(max_particles)
character*(8) str2(3,max_particles)
integer info_p(5,max_particles),iposx(3,max_particles)
common/to_external/iwave,owave,iposx,info_p,str2
character*(4*max_particles) particle(4)
integer charge_c(max_particles)
integer iparticle(0:max_particles,0:4),inverse(max_particles)
common/to_model/iparticle, particle, inverse, charge_c
logical major_exist
common/to_major/major_exist
integer nincoming,nincfirst
common/to_proc2/nincoming,nincfirst
integer ndcmax
parameter(ndcmax=20)
integer ndcpart,idcid(ndcmax),idcgroup(ndcmax)
logical dcfinal(ndcmax)
common/to_dc/ndcpart,idcid,idcgroup,dcfinal
! Data
!-----------
! Begin Code
!-----------
c
c Iline(0) = # partons iline(1)=parton_1 iline(2)=parton2 .....
c njet(loop) = # protons+jets things looping over for that type (P,J,L+ etc)
c icount(1,loop) tells what particle 1 is currently (u, u~, d....etc)
c ijet(1,loop) tells you which parton is jet #1. For PP-> w+jj ijet = {(1,2),(4,5)}
c
c
possible = .false.
do while (jetloop .and. .not. possible )
jetloop=.false.
c
c Loop to find first jet which isn't at maximum value (eg it can be incremented)
c Usually falls right through this. i=njets.
c
iloop = SumParticles(0,0) !Start at the outer most loop
foundone=.false.
do while (.not. foundone .and. iloop .ge. 1)
if (njets(iloop) .gt. 0) then
i = njets(iloop)
do while(icount(i,iloop) .eq. SumParticles(1,iloop)
$ .and. i .gt. 1)
i=i-1
enddo
foundone = (icount(i,iloop) .ne. SumParticles(1,iloop))
endif
if (.not. foundone) iloop=iloop-1
enddo
if (.not. foundone) then
jetloop = .false.
return
endif
c write(*,*) 'Incrementing',i,iloop
c read(*,*) j
c
c Now increment jet i by 1
c
icount(i,iloop)=icount(i,iloop)+1
c
c reset all "higher" jets to minimum new value.
c
do j=i+1,njets(iloop)
if (ijet(j,iloop) .le. nincoming) then
icount(j,iloop) = 1
else
icount(j,iloop) = icount(i,iloop) !Avoid double counting, unless it is P
endif
enddo
do kloop=iloop+1,SumParticles(0,0)
do j=1,njets(kloop)
icount(j,kloop)=1
enddo
enddo
c
c Now check and make sure everything looks OK.If so, set the partons to the
c appropriate value and set jetloop to be true.
c
do kloop=1,SumParticles(0,0)
do j=1,njets(kloop)
jetloop=.true.
if (icount(j,kloop) .le. SumParticles(1,kloop)) then
iline(ijet(j,kloop)) =
$ SumParticles(icount(j,kloop)+1,kloop)
else
c write(*,*) 'Done ',j,icount(j),npartons
jetloop=.false.
return
endif
enddo
enddo
c
c tjs 3/30/07
c set idcid values to new partons
c
iexternal = nincoming
do i=1,ndcpart
if (dcfinal(i)) then
iexternal=iexternal+1
idcid(i) = iline(iexternal)
endif
enddo
if (.true.) then !Use optimization
c
c Do a simple check to make sure the number of fermions is even
c
do i=-1,1
nf(i)=0
enddo
do i=1,iline(0)
if (info_p(3,iline(i)) .eq. 1) then !This is a fermion line
j = inverse(iline(i))-iline(i)
if (abs(j) .gt. 1) then
write(*,*) 'Error determining fermion in inc_jet',j
j=0
endif
nf(j) = nf(j)+1
endif
enddo
c
c Warning, this doesn't work with majoranas
c
if (nf(0) .eq. 0 .and. .not. major_exist) then
possible = (nf(-1) .eq. nf(1)) !match fermion with anti
else
write(*,*) 'Using even number',nf(0), major_exist
possible = ( mod(nf(-1)+nf(0)+nf(1),2) .eq. 0) !requires even number
c possible = .true.
endif
else
possible=.true.
endif
enddo !(possible)
call order_jets(iline(0))
end
Subroutine inc_jet_old(iline,jetloop)
c***********************************************************************
c Loops over the different possible partons in protons and jets
c***********************************************************************
implicit none
!Constants
include 'params.inc'
c integer npartons
c parameter (npartons=11)
! Arguments
integer iline(0:10)
logical jetloop
! Local
integer i,j,nf(-1:1)
logical possible
! Global
integer icode(npartons),njet,ijet(10),icount(10)
common /to_jets/icode, njet,ijet, icount
logical cross_opt
common /to_crossopt/ cross_opt
character*(max_string) iwave(max_particles),owave(max_particles)
character*(8) str2(3,max_particles)
integer info_p(5,max_particles),iposx(3,max_particles)
common/to_external/iwave,owave,iposx,info_p,str2
integer nincoming,nincfirst
common/to_proc2/nincoming,nincfirst
character*(4*max_particles) particle(4)
integer charge_c(max_particles)
integer iparticle(0:max_particles,0:4),inverse(max_particles)
common/to_model/iparticle, particle, inverse, charge_c
logical major_exist
common/to_major/major_exist
! Data
!-----------
! Begin Code
!-----------
c
c Iline(0) = # partons iline(1)=parton_1 iline(2)=parton2 .....
c njet = # protons+jets things looping over
c icount(1) tells what particle 1 is currently (u, u~, d....etc)
c ijet(1) tells you which parton is jet #1. For PP-> w+jj ijet = { 1,2,4,5}
c
c
possible = .false.
do while (jetloop .and. .not. possible )
jetloop=.false.
i = njet
c
c Loop to find first jet which isn't at maximum value (eg it can be incremented)
c Usually falls right through this. i=njet.
c
do while(icount(i) .eq. npartons .and. i .gt. 1)
i=i-1
enddo
c
c Now increment jet i by 1
c
icount(i)=icount(i)+1
c
c reset all "higher" jets to minimum new value.
c
do j=i+1,njet
if (ijet(i) .le. nincoming .and. .not. cross_opt) then
icount(j)=1 !Incremented initial state, start over
else
icount(j)=icount(i) !Increment final state, start at this point
endif
enddo
c
c Now check and make sure everything looks OK.If so, set the partons to the
c appropriate value and set jetloop to be true.
c
do j=1,njet
jetloop=.true.
if (icount(j) .le. npartons) then
c jetloop=.true.
iline(ijet(j)) = icode(icount(j))
else
c write(*,*) 'Done ',j,icount(j),npartons
jetloop=.false.
return
endif
enddo
if (.true.) then !Use optimization
c
c Do a simple check to make sure the number of fermions is even
c
do i=-1,1
nf(i)=0
enddo
do i=1,iline(0)
if (info_p(3,iline(i)) .eq. 1) then !This is a fermion line
j = inverse(iline(i))-iline(i)
if (abs(j) .gt. 1) then
write(*,*) 'Error determining fermion in inc_jet',j
j=0
endif
nf(j) = nf(j)+1
endif
enddo
c
c Warning, this doesn't work with majoranas
c
if (nf(0) .eq. 0 .and. .not. major_exist) then
possible = (nf(-1) .eq. nf(1)) !match fermion with anti
else
write(*,*) 'Using even number',nf(0), major_exist
possible = ( mod(nf(-1)+nf(0)+nf(1),2) .eq. 0) !requires even number
c possible = .true.
endif
else
possible=.true.
endif
enddo !(possible)
call order_jets(iline(0))
end
Subroutine get_order_old2
c***********************************************************************
c Determines the appropriate order of the different coupling
c constants based on information about the external particles
c and also based on user input.
c***********************************************************************
implicit none
! Constants
include 'params.inc'
! Local
integer i
! Global Variables
integer iline(-maxlines:maxlines),idir(-maxlines:maxlines)
integer this_coup(max_coup) ,goal_coup(max_coup)
common/to_proc/iline,idir,this_coup,goal_coup
character*(10) coup_name(max_coup)
integer ncoups
common/to_couplings/ncoups,coup_name
!-----------
! Begin Code
!-----------
do i=1,ncoups
write(*,'(a,a$)') 'Enter maximum number of vertices for ',
& coup_name(i)
read(*,*) goal_coup(i)
if (goal_coup(i) .lt. 0) goal_coup(i)=0
enddo
end
Subroutine get_order
c***********************************************************************
c Determines the appropriate order of the different coupling
c constants based on information about the external particles
c and also based on user input.
c***********************************************************************
implicit none
! Constants
include 'params.inc'
! Local
integer i,j
logical done
character*50 buff
character*10 coupname
integer coupvalue
! Global Variables
integer iline(-maxlines:maxlines),idir(-maxlines:maxlines)
integer this_coup(max_coup) ,goal_coup(max_coup)
common/to_proc/iline,idir,this_coup,goal_coup
character*(10) coup_name(max_coup)
integer ncoups
common/to_couplings/ncoups,coup_name
!-----------
! Begin Code
!-----------
done = .false.
do i=1,ncoups
goal_coup(i) = 0
enddo
do while (.not. done)
write(*,'(a,a)') 'Enter maximum number of vertices for'
$ ,' eg QCD = 4 (type "end_coup" to finish)'
read(*,'(a)') ,buff
call upper_case(buff)
11 if (index(buff,"END_COUP") .gt. 0) then
done = .true.
return
endif
call get_coup_name(buff,coupname,coupvalue)
if (coupname(1:1) .ne. " ") then
i = 1
do while (coup_name(i) .ne. coupname .and. i .lt. ncoups)
i=i+1
enddo
if (coup_name(i) .eq. coupname) then
goal_coup(i) = coupvalue
j = index(coupname," ")
if ( j .eq. 0) then
j = 10
endif
write(*,*) 'Setting ',coupname(1:j),' = ', coupvalue
endif
endif
enddo
end
subroutine get_coup_name(buff,coupname,coupvalue)
c**********************************************************************
c Extracts from buff, the coupling name and coupling value
c Assumes it is in the format coup = value
c**********************************************************************
implicit none
c
c Arguments
c
character*(*) buff
character*(*) coupname
integer coupvalue
c
c Local
c
integer i,j,k
c-----
c Begin Code
c-----
i = index(buff,"=")
coupname = " "
coupvalue = 0
c write(*,*) "Got coupling ",buff(:i)
if (i > 0) then
j=1
do while (j .lt. i .and. buff(j:j) .eq. ' ')
j=j+1
enddo
k=j
do while (k .lt. i-1 .and. buff(k:k) .ne. ' ')
k=k+1
enddo
coupname = buff(j:k)
read(buff(i+1:),*,err=99,end=99) coupvalue
endif
c write(*,*) coupname, j,k,i
99 continue
end
Subroutine get_order_old
c***********************************************************************
c Determines the appropriate order of the different coupling
c constants based on information about the external particles
c and also based on user input.
c Input is from common block iline and
c***********************************************************************
implicit none
! Constants
include 'params.inc'
c integer maxlines , max_coup
c parameter (maxlines=8, max_coup=5)
c integer max_string , max_particles
c parameter (max_string=120, max_particles=2**7-1)
! Local
integer i,nqfd,in1,wpart(0:3)
integer reqorder(max_coup),imin,imax
character*25 input
character*10 snum
logical done
! Global Variables
integer iline(-maxlines:maxlines),idir(-maxlines:maxlines)
integer this_coup(max_coup) ,goal_coup(max_coup)
common/to_proc/iline,idir,this_coup,goal_coup
character*(max_string) iwave(max_particles),owave(max_particles)
character*(8) str2(3,max_particles)
integer info_p(5,max_particles),iposx(3,max_particles)
common/to_external/iwave,owave,iposx,info_p,str2
logical lwp,lwm,lz,decay,cross
common/to_decay/lwp,lwm,lz,decay,cross
data snum /'0123456789'/
data wpart/0,0,0,0/
!-----------
! Begin Code
!-----------
do i=1,max_coup
reqorder(i)=0
enddo
do i=1,iline(0)
c if (info_p(5,iline(i)) .ne. 0) then !info_p(5,i) now used for particle ID
c if (info_p(5,iline(i)) .le. max_coup) then
c reqorder(info_p(5,iline(i)))=
c & reqorder(info_p(5,iline(i)))+1
c else
c write(*,*)'Order of particle too big in readproc'
c endif
c endif
enddo
imin = 0
reqorder(2)=reqorder(2)+reqorder(3)+reqorder(4)
do i=1,2
if (reqorder(i) .gt. iline(0)-2) reqorder(i)=iline(0)-2
imin=imin+reqorder(i)
enddo
if (imin .gt. iline(0)-2) then
write(*,*)'Sorry this process is not possible at tree level'
write(*,*)'Well try our best'
reqorder(2)=iline(0)-2-reqorder(1)
c stop
endif
imin=reqorder(1)
imax=iline(0)-2-reqorder(2)-reqorder(5)
write(*,'(a,i1,a,i1,a,i1,a)')
& 'Enter the number of QCD vertices between ',
& imin,' and ',imax,' (',imax,'): '
read(*,'(a)') input
i=0
done=.false.
do while(i .lt. 25 .and. .not. done)
i=i+1
in1 = index(snum(imin+1:imax+1),input(i:i))
if (in1 .ne. 0) then
goal_coup(1) = imin+in1-1
done=.true.
else
goal_coup(1) = imax
endif
enddo
goal_coup(2) = iline(0)-2-goal_coup(1)-reqorder(4)
goal_coup(3) = reqorder(3)
goal_coup(4) = reqorder(4)
imin = reqorder(2)
imax = 9
write(*,'(a,i1,a,i1,a,i1,a)')
& 'Enter the number of QFD vertices between ',
& imin,' and ',imax,' (',imin,'): '
read(*,'(a)') input
i=0
done=.false.
do while(i .lt. 25 .and. .not. done)
i=i+1
in1 = index(snum(imin+1:imax+1),input(i:i))
if (in1 .ne. 0) then
goal_coup(2) = imin+in1-1
done=.true.
else
goal_coup(2) = imin
endif
enddo
imin = reqorder(4)
imax = 9
write(*,'(a,i1,a,i1,a,i1,a)')
& 'Enter the number of BRS vertices between ',
& imin,' and ',imax,' (',imin,'): '
read(*,'(a)') input
i=0
done=.false.
do while(i .lt. 25 .and. .not. done)
i=i+1
in1 = index(snum(imin+1:imax+1),input(i:i))
if (in1 .ne. 0) then
goal_coup(4) = imin+in1-1
done=.true.
else
goal_coup(4) = imin
endif
enddo
write(*,'(a,i1)') 'The number of QFD vertices is ',goal_coup(2)
if (goal_coup(3) .eq. 0 .and. goal_coup(2) .gt. 0) then
write(*,'(a)') 'Would you like to include the Weak sector (n)?'
read(*,'(a)') input
nqfd=index(input,'y')
if (nqfd .eq. 0) nqfd = index(input,'Y')
if (nqfd .ne. 0) nqfd = 1
elseif (goal_coup(3) .gt. 0) then
write(*,'(a)') 'QFD required for this process ok?: '
read(*,'(a)') input
else
write(*,'(a)') 'No QFD possible all QCD ok?: '
read(*,'(a)') input
endif
if (nqfd .eq. 1) then
goal_coup(3)=goal_coup(3)+goal_coup(2)
endif
c goal_coup(2)=9
write(*,'(a,10i4)') 'Max Couplings',(goal_coup(i),i=1,max_coup)
c
c Check if need to decay final particle
c
if (wpart(0) .eq. 0) then
call getparticle('w+w-z',wpart(1),wpart(0))
if (wpart(0) .ne. 3) then
write(*,*)'Warning couldnt find WZ boson codes'
endif
endif
decay = .false.
do i=1,wpart(0)
if (iline(iline(0)) .eq. wpart(i)) decay=.true.
enddo
if (decay) then
write(*,'(a)') 'Would you like to decay the final boson (n)?'
read(*,'(a)') input
i=index(input,'y')
if (i .eq. 0) i = index(input,'Y')
if (i .eq. 0) decay=.false.
else
write(*,'(a)') 'Last particle can not be decayed. ok?:'
read(*,'(a)') input
endif
c call loadmodel(goal_coup(1),goal_coup(2),goal_coup(3))
c if (goal_coup(1).gt. 0) call addQCD
c if (goal_coup(2) +goal_coup(3)+goal_coup(4).gt. 0) call addQED
c if (nqfd .gt. 0 .or. goal_coup(3)+goal_coup(4).gt. 0) call addQFD
end
subroutine read_dc(xbuff,iline,nparticles)
c***************************************************************************
c Parses buff to find topology groups for decay chain
c
c Uses subgroup ids so that a first mother, and its final state daughters
c has id 10000000, while a daughter who is in its turn a mother gets
c 11000000 and so on down the chain. By sorting on group ids we
c automatically get the order
c (mother,final-state daughters,decaying daughters)
c Additional particles are in group 0 and are last in the sorted chain.
c The topological groups are then set such that the first final-state
c daughter in the list above defines a new group, and all daughters on
c same or lower level are put in this group. Example
c (skipping 5 trailing 0s in group ids):
c
c g g > (t~ > (W- > e- ve~) b~ )(t > b (W+ > e+ ve ))
c
c subgroup: 100 110 110 110 100 200 200 210 210 210
c final: F F T T T F T F T T
c part nr: 1 2 4 5 3 6 7 8
c top.group: 1 1 1 2 2 2
c
c The sorted list of particle ids, subgroup numbers and "final" flag are
c passed through the common block to_dc (where the incoming particles
c are not included in ndcpart or the arrays.
c
c***************************************************************************
implicit none
! Constants
include 'params.inc'
integer char_A, char_Z
c parameter (char_A = ichar('A'), char_Z = ichar('Z'))
integer lcshift
c parameter (lcshift = ichar('a') - ichar('A'))
! Arguments
character*(*) xbuff
integer iline(*),nparticles
! Global
character*(4*max_particles) particle(4)
integer charge_c(max_particles)
integer iparticle(0:max_particles,0:4),inverse(max_particles)
common/to_model/iparticle, particle, inverse, charge_c
character*(max_string) iwave(max_particles),owave(max_particles)
integer iposx(3,max_particles)
integer info_p(5,max_particles)
character*(8) str(3,max_particles)
common/to_external/iwave,owave,iposx,info_p,str
integer nincoming,nincfirst
common/to_proc2/nincoming,nincfirst
integer ndcmax
parameter(ndcmax=20)
integer ndcpart,idcid(ndcmax),idcgroup(ndcmax)
logical dcfinal(ndcmax)
common/to_dc/ndcpart,idcid,idcgroup,dcfinal
integer SumParticles(0:maxpartons,0:maxloops)
integer icount(maxpartons,maxloops)
integer njets(0:maxpartons)
integer ijet(maxpartons,maxloops)
common/to_SumParticles/ SumParticles,icount,ijet,njets
logical flip(maxlines)
common/to_flip/flip
! data flip/maxlines*.true./
! External
integer groupid
external groupid
! Local
integer npartmax
parameter(npartmax=20)
character*(max_string) buff
integer i,in1,in2,in3,in4,j,k,ii,jj
integer npar,igroup,ksort(npartmax),ktmp,igrtop,izeroes,nzeroes
external izeroes,nzeroes
integer nmopar(npartmax),kback(npartmax)!,ndapar(npartmax)
logical final,foundp,moth(0:npartmax),flipdc(1:npartmax)
integer npart,ipgroup(npartmax),ipext(npartmax),ipid(npartmax)
logical pfinal(npartmax),ident,multiparts
integer identfact(npartmax),identnum(npartmax)
integer nsumparts,in,nchar,n,istrparts,maxpar,maxd
integer isumgr(maxloops),ilabel(maxloops),isumid(maxloops)
character*4 namesum,str1
character*(max_string) strparts
integer nmothers(0:npartmax),idaughters(0:npartmax,npartmax,3)
integer i2daughters(0:npartmax,npartmax,3),ndaughters(npartmax)
integer ipvalue(npartmax),i2pvalue(npartmax),imoth,nferm
!-----
! Begin Code
!-----
char_A = ichar('A')
char_Z = ichar('Z')
lcshift = ichar('a') - ichar('A')
buff = xbuff
do i=1,len(xbuff)
if (ichar(buff(i:i)) .ge. char_A .and.
& ichar(buff(i:i)) .le. char_Z) then
buff(i:i)=char(ichar(buff(i:i))+lcshift)
endif
enddo
i=1 ! index(xbuff,'>')+1
npar =0 ! Number of parentheses
igroup=0 ! Present group number
npart =0 ! Number of particles found
final =.true. ! Present particle final state?
moth(0)=.false.
multiparts=.false.
maxpar = 0
do j=1,npartmax
nmothers(j)=0
flipdc(j)=.true.
enddo
if(index(buff,'(').ne.0) then
write(*,*) 'Decay chain process ',buff(1:len_trim(buff))
endif
C Step through the string and look for parentheses, ">" and particles
do while(i.le.len_trim(buff))
if(buff(i:i).eq.'(')then
npar=npar+1
nmopar(npar)=0
c ndapar(npar)=0
moth(npar)=.true.
if(buff(i-1:i-1).eq.')')
$ igroup=igroup+10**(8-npar)
igroup=igroup+10**(8-npar)
final=.false.
i=i+1
else if(buff(i:i).eq.'>')then
c ndapar(npar)=0
if(.not.moth(npar)) then
write(*,*) 'Error: ''>'' in wrong place '//
$ '- must be in parentheses'
STOP
endif
moth(npar)=.false.
final=.true.
c Set information about tree for sorting
idaughters(npar,nmothers(npar),2)=npart+1
i=i+1
else if(buff(i:i).eq.')')then
igroup=igroup-10**(8-npar)
i=i+1
if(nmopar(npar).ne.1)then
write(*,*) 'Error: ',nmopar(npar),' mothers! Should be 1!'
STOP
endif
c Set information about tree for sorting
idaughters(npar,nmothers(npar),3)=npart
npar=npar-1
if(npar.lt.0) then
write(*,*) 'Error: Too many closing parentheses!'
STOP
endif
pfinal(npart)=.true.
c print *,' set final to ',pfinal(npart)
else if(buff(i:i).eq.'/')then
c We've reached the "exclude particles", done reading
goto 10
else
C Identify particles and set group and final flag
in4 = index(particle(4),buff(i:i+3))-1
in3 = index(particle(3),buff(i:i+2))-1
in2 = index(particle(2),buff(i:i+1))-1
in1 = index(particle(1),buff(i:i+0))-1
foundp=.false.
if (mod(in4,4) .eq. 0) then
npart=npart+1
ipid(npart)= iparticle(in4/4+1,4)
c print*,npart,': Got one ',particle(4)(in4+1:in4+4)
i=i+4
foundp=.true.
elseif (mod(in3,3) .eq. 0) then
npart=npart+1
ipid(npart)= iparticle(in3/3+1,3)
c print*,npart,': Got one ',particle(3)(in3+1:in3+3)
i=i+3
foundp=.true.
elseif (mod(in2,2) .eq. 0) then
npart=npart+1
ipid(npart)= iparticle(in2/2+1,2)
c print*,npart,': Got one ',particle(2)(in2+1:in2+2)
i=i+2
foundp=.true.
elseif (mod(in1,1) .eq. 0 .and. in1 .ge. 0) then
npart=npart+1
ipid(npart)= iparticle(in1/1+1,1)
c print*,npart,': Got one ',particle(1)(in1+1:in1+1)
i=i+1
foundp=.true.
else
buff=buff(1:i-1)//buff(i+1:)
endif
if(foundp)then
if(npar.eq.0)then
pfinal(npart)=.true.
ipgroup(npart)=0
else
pfinal(npart)=final
ipgroup(npart)=igroup
if(moth(npar)) then
nmopar(npar)=nmopar(npar)+1
c Set information about tree for sorting
nmothers(npar)=nmothers(npar)+1
if(npar.gt.maxpar) maxpar=npar
idaughters(npar,nmothers(npar),1)=npart
c else
c ndapar(npar)=ndapar(npar)+1
endif
endif
c print *,' ',ipid(npart),' with group ',ipgroup(npart),
c $ ' and final = ',pfinal(npart)
endif
endif
enddo
10 if(npar.gt.0) then
write(*,*) 'Error: Too few closing parentheses!'
STOP
endif
if(npar.lt.0) then
write(*,*) 'Error: Too many closing parentheses!'
STOP
endif
if(npart.le.0) then
write(*,*) 'Error: No particles found!'
STOP
endif
c print *,'Particles: id, group, final'
c do i=1,npart
c print *,i,ipid(i),ipgroup(i),pfinal(i)
c enddo
nmothers(0)=1
idaughters(0,1,1)=0
idaughters(0,1,2)=1
idaughters(0,1,3)=npart
i2daughters(0,1,1)=0
i2daughters(0,1,2)=1
i2daughters(0,1,3)=npart
C Check for multiparticle labels and make sure no same label occurs
C in different groups
do i=1,SumParticles(0,0)
isumgr(i) = -1
isumid(i) = 0
ilabel(i) = 0
enddo
nsumparts=SumParticles(0,0)
do i=1,npart
do j=1,nsumparts
if (ipid(i) .eq. SumParticles(0,j)) then
multiparts=.true.
write(*,*) 'Found multiparticle: ',i,j
if(isumgr(j).eq.-1)then
isumid(j)=ipid(i)
else if(isumgr(j).ne.ipgroup(i))then
c print *,'New group: ',isumgr(j),ipgroup(i)
ilabel(j)=ilabel(j)+1
strparts=''
istrparts=0
call part_string(ipid(i),namesum,nchar)
if(nchar.ge.4) nchar=3
write(namesum(nchar+1:nchar+1),'(i1)') ilabel(j)
do while(index(particle(nchar+1),namesum(:nchar+1)).gt.0)
ilabel(j)=ilabel(j)+1
write(namesum(nchar+1:nchar+1),'(i1)') ilabel(j)
enddo
do k=1,sumparticles(1,j)
call part_string(sumparticles(k+1,j),str1,n)
strparts(istrparts+1:istrparts+n)=str1(1:n)
istrparts=istrparts+n
enddo
c print *,'Adding ',namesum,sumparticles(1,j),strparts
call AddLoopParticles(namesum(:nchar+1),strparts)
in=index(particle(nchar+1),namesum(:nchar+1))-1
isumid(j)=iparticle(in/(nchar+1)+1,nchar+1)
else
c print *,'Same group: ',isumgr(j),ipgroup(i)
endif
ipid(i)=isumid(j)
isumgr(j)=ipgroup(i)
endif
enddo
enddo
C Sort the particles according to the group
do i=1,npart
ksort(i)=i
enddo
do i=npart,2,-1
do j=2,i
if((ipgroup(ksort(j)).lt.ipgroup(ksort(j-1)).or.
$ ipgroup(ksort(j-1)).eq.0).and.ipgroup(ksort(j)).ne.0)then
ktmp=ksort(j)
ksort(j)=ksort(j-1)
ksort(j-1)=ktmp
endif
enddo
enddo
C kback maps in other direction
do i=1,npart
kback(ksort(i))=i
enddo
C Sort mother-daughter info
c print *,'Mother daughter1, daughtern (bef. sort)'
do i=0,maxpar
c print *,'par: ',i,': mothers: ',nmothers(i)
do j=1,nmothers(i)
c print *,(idaughters(i,j,k),k=1,3)
i2daughters(i,j,1)=kback(idaughters(i,j,1))
i2daughters(i,j,3)=i2daughters(i,j,1)+1+
$ idaughters(i,j,3)-idaughters(i,j,2)
i2daughters(i,j,2)=i2daughters(i,j,1)+1
enddo
enddo
c print *,'Mother daughter1, daughtern (after sort)'
c do i=1,maxpar
c print *,'par: ',i,': mothers: ',nmothers(i)
c do j=1,nmothers(i)
c print *,(i2daughters(i,j,k),k=1,3)
c enddo
c enddo
C Fill common block arrays
ndcpart=npart
do i=1,npart
idcid(i)=ipid(ksort(i))
idcgroup(i)=ipgroup(ksort(i))
dcfinal(i)=pfinal(ksort(i))
write(*,*) 'Part Info after sort: ',
$ i,idcid(i),idcgroup(i),dcfinal(i)
enddo
C Check for bosons decaying to two fermions, in that case
C set majorana fermion flow flip for one of them to false
do i=1,maxpar
do j=1,nmothers(i)
imoth=i2daughters(i,j,1)
if(info_p(2,idcid(imoth)).ne.2)then
nferm=0
do ii=i2daughters(i,j,2),i2daughters(i,j,3)
if(info_p(2,idcid(ii)).eq.2.and.dcfinal(ii))then
nferm=nferm+1
endif
enddo
if(nferm.eq.2)then
do ii=i2daughters(i,j,2),i2daughters(i,j,3)
if(info_p(2,idcid(ii)).eq.2.and.dcfinal(ii))then
flipdc(ii)=.false.
goto 100
endif
enddo
100 continue
endif
endif
enddo
enddo
do i=1,npart
write(*,*) 'Final part info: ',
$ i,idcid(i),idcgroup(i),dcfinal(i),flipdc(i)
enddo
C Define external particles and set group ids for them
do i = 1, nincoming
call setgroupid(i,0)
call setgroupid(-i,0)
enddo
nparticles=0
igroup=1
igrtop=0
do i=1,npart
if(dcfinal(i))then
nparticles=nparticles+1
iline(nparticles)=idcid(i)
flip(nparticles)=flipdc(i)
call setgroupid(nparticles+nincoming,0)
call setgroupid(-(nparticles+nincoming),0)
if(idcgroup(i).ne.0)then
c Check if new group, e.g.
c if igroup=11000000 then 11100000 is same group, but
c 12000000 or 20000000 is new group
if(idcgroup(i)-igroup.ge.izeroes(igroup) .or. .true.)then
c New group of final state particles
igroup=idcgroup(i)
c igrtop=igrtop+1
igrtop = idcgroup(i)
c print *,'Set top. groupid for particle ',
c $ nparticles+nincoming,' (',i,') to ',igrtop
c print *,'Set to group mother'
call setgroupid(nparticles+nincoming,igrtop)
c call setmother(nparticles+nincoming)
else
c Same group as last one
call setgroupid(nparticles+nincoming,igrtop)
c print *,'Set top. groupid for particle ',
c $ nparticles+nincoming,' (',i,') to ',igrtop
endif
endif
endif
enddo
c read(*,*) i
c call orderparticles
return
end
subroutine write_dc(buff,nlen,iparticles,nparticles)
c***************************************************************************
c Prints out decay chain given particles
c Note that it doesn't print incoming particles, so these should
c already be in buff
c - buff is character buffer (should be max_string in length)
c - nlen is starting position in buff, and gives back ending position
c - iparticles are particle id:s, including intermediate states
c - nparticles is the number of id:s in iparticles. Must be = ndcpart.
c***************************************************************************
implicit none
! Constants
include 'params.inc'
integer char_A, char_Z
c parameter (char_A = ichar('A'), char_Z = ichar('Z'))
integer lcshift
c parameter (lcshift = ichar('a') - ichar('A'))
! Arguments
character*(*) buff
integer nlen,iparticles(*),nparticles
! Global
character*(4*max_particles) particle(4)
integer charge_c(max_particles)
integer iparticle(0:max_particles,0:4),inverse(max_particles)
common/to_model/iparticle, particle, inverse, charge_c
integer nincoming,nincfirst
common/to_proc2/nincoming,nincfirst
integer ndcmax
parameter(ndcmax=20)
integer ndcpart,idcid(ndcmax),idcgroup(ndcmax)
logical dcfinal(ndcmax)
common/to_dc/ndcpart,idcid,idcgroup,dcfinal
c Local
integer i,nchar,itemp, nopen
integer npar,igroup,izeroes
c External
integer groupid
external izeroes
if(nparticles.ne.ndcpart) then
write(*,*) 'Error: write_dc called with nparticles != ndcpart'
stop
endif
npar=0
igroup=0
nopen = 0
do i=1,nparticles
c print *,i,idcid(i),idcgroup(i),dcfinal(i),igroup,izeroes(igroup)
if(npar.gt.0.and.(idcgroup(i)-igroup.ge.izeroes(igroup).or.
$ idcgroup(i).eq.0))then
itemp=igroup
c print *,'npar,itemp',npar,itemp
do while(idcgroup(i)-itemp.ge.izeroes(itemp).or.
$ (idcgroup(i).eq.0.and.npar.gt.0))
buff(nlen:nlen)=')'
nlen=nlen+1
nopen = nopen - 1
itemp = itemp+10**(8-npar)
if(itemp.lt.0)then
write(*,*) 'Error:Writing of process failed, itemp < 0'
stop
endif
npar=npar-1
c print *,'npar,itemp',npar,itemp
enddo
c if(idcgroup(i).gt.0) then
c npar=npar+1
c buff(nlen:nlen)='('
c nlen=nlen+1
c endif
endif
if (idcgroup(i).gt.igroup) then
npar=npar+1
buff(nlen:nlen) = '('
nlen=nlen+1
nopen=nopen+1
endif
call part_string(iparticles(i),buff(nlen:nlen+3),nchar)
nlen = nlen+nchar
if (.not.dcfinal(i)) then
buff(nlen:nlen) = '>'
nlen = nlen+1
endif
igroup=idcgroup(i)
if(nlen.gt. max_string)then
write(*,*) 'Error: Too long string of particles, exceeding ',
$ max_string
stop
endif
enddo
c
c tjs 3/30/07
c added closing parenthesis
c
do i=1,nopen
buff(nlen:nlen)=')'
nlen=nlen+1
enddo
write(*,*) 'buff = ',buff
return
end
function izeroes(i)
c***************************************************************************
c If i=211000, izeroes returns 1000, i.e. a 1 with same number of
c trailing zeroes as i
c***************************************************************************
implicit none
integer izeroes,i,j
izeroes=i
if(i.lt.10) return
j=0
do while(mod(i,int(10**j)).eq.0)
j=j+1
enddo
izeroes=int(10**(j-1))
return
end
function nzeroes(i)
c***************************************************************************
c If i=211000, izeroes returns 1000, i.e. a 1 with same number of
c trailing zeroes as i
c***************************************************************************
implicit none
integer nzeroes,i,j
nzeroes=0
if(i.lt.10) return
j=0
do while(mod(i,int(10**j)).eq.0)
j=j+1
enddo
nzeroes=j-1
return
end
subroutine OrderParticles(ndcpart,idcid,idcgroup,dcfinal)
c*************************************************************************
c Routine to place the particles in a unique order such that
c we can easily determine if two processes are identical
c to avoid double counting.
c*************************************************************************
implicit none
integer ndcmax
parameter(ndcmax=20)
integer npartmax
parameter(npartmax=20)
c
c Arguments
c
integer ndcpart,idcid(ndcmax),idcgroup(ndcmax)
logical dcfinal(ndcmax)
c
c Local
c
integer i,j,k,npart,ktmp,npar,igroup,itemp,maxd,mind,ii,jj
integer ksort(npartmax),ipid(npartmax),ipgroup(npartmax)
integer nmothers(0:npartmax),idaughters(0:npartmax,npartmax,3)
integer i2daughters(0:npartmax,npartmax,3),ndaughters(npartmax)
integer ipvalue(npartmax),i2pvalue(npartmax),imoth,maxpar
logical pfinal(npartmax)
integer izeroes,nzeroes
external izeroes,nzeroes
c
c Global
c
integer ndcpart_g,idcid_g(ndcmax),idcgroup_g(ndcmax)
logical dcfinal_g(ndcmax)
common/to_dc/ndcpart_g,idcid_g,idcgroup_g,dcfinal_g
c-----
c Begin Code
c-----
c print *,'In OrderParticles'
c
c First create local copy of global variables
c Don't want to change globals, only local
c
ndcpart = ndcpart_g
do i = 1, ndcpart
idcid(i) = idcid_g(i)
idcgroup(i) = idcgroup_g(i)
dcfinal(i) = dcfinal_g(i)
enddo
npart = ndcpart
C Loop through particles to find mother-daughter structure
do j=1,npartmax
nmothers(j)=0
enddo
maxpar = 0
nmothers(0)=1
i2daughters(0,1,1)=0
i2daughters(0,1,2)=1
i2daughters(0,1,3)=npart
npar=0
igroup=0
c print *,'i,idcid(i),idcgroup(i),dcfinal(i),igroup,izeroes(igroup)'
do i=1,npart
c print *,i,idcid(i),idcgroup(i),dcfinal(i),igroup,izeroes(igroup)
if(npar.gt.0.and.(idcgroup(i)-igroup.ge.izeroes(igroup).or.
$ idcgroup(i).eq.0))then
itemp=igroup
c print *,'npar,itemp',npar,itemp
do while(idcgroup(i)-itemp.ge.izeroes(itemp).or.
$ (idcgroup(i).eq.0.and.npar.gt.0))
c Set information about tree for sorting
i2daughters(npar,nmothers(npar),3)=i-1
c print *,'idaughters end: ',npar,
c $ i2daughters(npar,nmothers(npar),3)
itemp = itemp+10**(8-npar)
if(itemp.lt.0)then
write(*,*) 'Error:Writing of process failed, itemp < 0'
stop
endif
npar=npar-1
c print *,'npar,itemp',npar,itemp
enddo
c if(idcgroup(i).gt.0) then
c npar=npar+1
c buff(nlen:nlen)='('
c nlen=nlen+1
c endif
endif
if (idcgroup(i).gt.igroup) then
npar=npar+1
endif
if (.not.dcfinal(i)) then
c Set information about tree for sorting
nmothers(npar)=nmothers(npar)+1
if(npar.gt.maxpar) maxpar=npar
i2daughters(npar,nmothers(npar),1)=i
i2daughters(npar,nmothers(npar),2)=i+1
c print *,'i, npar, nmothers: ',i,npar,nmothers(npar)
c print *,'idaughters: ',i2daughters(npar,nmothers(npar),1),
c $ i2daughters(npar,nmothers(npar),2)
endif
igroup=idcgroup(i)
enddo
c Close parentheses
do while(npar.gt.0)
c Set information about tree for sorting
i2daughters(npar,nmothers(npar),3)=npart
c print *,'idaughters end: ',npar,
c $ i2daughters(npar,nmothers(npar),3)
npar=npar-1
enddo
C Start by defining particle labels for the particles,
C in same order as particle ids; just a way to reduce number of
C particle ids
do i=1,npart
ksort(i)=i
enddo
do i=npart,2,-1
do j=2,i
if(idcid(ksort(j)).lt.idcid(ksort(j-1)))then
ktmp=ksort(j)
ksort(j)=ksort(j-1)
ksort(j-1)=ktmp
endif
enddo
enddo
do i=1,npart
ipvalue(ksort(i))=i
if(i.gt.1.and.idcid(ksort(i)).eq.idcid(ksort(i-1)))then
ipvalue(ksort(i))=ipvalue(ksort(i-1))
endif
enddo
c print *,'Particle ids:',(ipvalue(i),i=1,npart)
c do i=0,maxpar
c do j=1,nmothers(i)
c print *,'idaughters(',i,j,')=',(i2daughters(i,j,ii),ii=1,3)
c enddo
c enddo
do i=1,npart
ksort(i)=i
enddo
C First sort final state particles in all groups
do i=0,maxpar
do j=1,nmothers(i)
k=i2daughters(i,j,2)
mind=i2daughters(i,j,2)
maxd=mind-1
do while (dcfinal(k).and.k.le.i2daughters(i,j,3))
c Find last final state particle
maxd=k
k=k+1
enddo
if(i.eq.0)then
c If 0 pars, final state particles at end of list
do ii=1,npart
if(idcgroup(ii).eq.0)then
mind=ii
maxd=npart
goto 10
endif
enddo
endif
10 do ii=maxd,mind+1,-1
do jj=mind+1,ii
if(idcid(ksort(jj)).lt.idcid(ksort(jj-1)))then
ktmp=ksort(jj)
ksort(jj)=ksort(jj-1)
ksort(jj-1)=ktmp
endif
enddo
enddo
c print *,'Sorted fs states: ',(ksort(ii),ii=
c $ mind,maxd)
C Calculate fs value for mother (if there is one)
if(i.gt.0)then
do ii=1,maxd-mind+1
ipvalue(i2daughters(i,j,1))=ipvalue(i2daughters(i,j,1))+
$ (npart+1)**ii*ipvalue(ksort(i2daughters(i,j,2)+ii-1))
ndaughters(i2daughters(i,j,1))=ii
enddo
c print *,'Value for ',i2daughters(i,j,1),': ',i,j,
c $ ipvalue(i2daughters(i,j,1))
endif
enddo
enddo
C Perform the sorting to avoid confusion
do i=1,npart
ipid(i)=idcid(ksort(i))
ipgroup(i)=idcgroup(ksort(i))
pfinal(i)=dcfinal(ksort(i))
i2pvalue(i)=ipvalue(ksort(i))
write(*,*) 'Part Info after sort: ',
$ i,ksort(i),ipid(i)
enddo
C Synchronize arrays
do ii=1,npart
idcid(ii)=ipid(ii)
idcgroup(ii)=ipgroup(ii)
dcfinal(ii)=pfinal(ii)
ipvalue(ii)=i2pvalue(ii)
enddo
C Now sort the mothers, starting with the outermost ones (with
C largest number of parentheses). Algorithm: Compare value of
C mothers which are within the decay products of same grandmother
C and sort, thereby working one's way up to the top decays.
do i=maxpar,1,-1
j=1
imoth=1
do while (j.le.nmothers(i))
C Find mother of mothers (grandmother)
do while (i2daughters(i,j,1).gt.i2daughters(i-1,imoth,3))
imoth=imoth+1
enddo
k=j+1
C Find last daughter of present grandmother
do while (k.le.nmothers(i).and.
$ i2daughters(i,k,1).lt.i2daughters(i-1,imoth,3))
k=k+1
enddo
k=k-1
C Sort mothers according to value
do ii=j,k
ksort(ii)=ii
enddo
c print *,'mothers, values: ',
c $ (i2daughters(i,ksort(jj),1),jj=j,k),
c $ (i2pvalue(i2daughters(i,ksort(jj),1)),jj=j,k)
do ii=k,j+1,-1
do jj=j+1,ii
if(i2pvalue(i2daughters(i,ksort(jj),1)).lt.
$ i2pvalue(i2daughters(i,ksort(jj-1),1)))then
ktmp=ksort(jj)
ksort(jj)=ksort(jj-1)
ksort(jj-1)=ktmp
endif
enddo
enddo
c print *,'Sorted mothers:',(ksort(ii),ii=j,k)
C Add sorted mother values to grandmother
if(i.gt.1)then
jj=i2daughters(i-1,imoth,1)
ndaughters(jj)=ndaughters(jj)+1
do ii=j,k
ipvalue(jj)=ipvalue(jj)+
$ (npart+1)**ndaughters(jj)*
$ ipvalue(i2daughters(i,ksort(ii),1))
ndaughters(jj)=ndaughters(jj)+
$ ndaughters(i2daughters(i,ksort(ii),1))
enddo
c print *,'ipvalue(',jj,')=',ipvalue(jj)
endif
C Set new mother info from sorting
jj=i2daughters(i,j,1)
do ii=j,k
idaughters(i,ii,1)=jj
idaughters(i,ii,2)=jj+1
idaughters(i,ii,3)=jj+i2daughters(i,ksort(ii),3)-
$ i2daughters(i,ksort(ii),2)+1
jj=idaughters(i,ii,3)+1
enddo
imoth=imoth+1
j=k+1
enddo
C Perform reshuffling of particles according to sort
do ii=1,nmothers(i)
do jj=0,idaughters(i,ii,3)-idaughters(i,ii,1)
c print *,'new, old: ',
c $ idaughters(i,ii,1)+jj,i2daughters(i,ksort(ii),1)+jj
idcid(idaughters(i,ii,1)+jj)=
$ ipid(i2daughters(i,ksort(ii),1)+jj)
idcgroup(idaughters(i,ii,1)+jj)=
$ ipgroup(i2daughters(i,ksort(ii),1)+jj)
dcfinal(idaughters(i,ii,1)+jj)=
$ pfinal(i2daughters(i,ksort(ii),1)+jj)
ipvalue(idaughters(i,ii,1)+jj)=
$ i2pvalue(i2daughters(i,ksort(ii),1)+jj)
enddo
enddo
C Synchronize arrays
do ii=1,npart
ipid(ii)=idcid(ii)
ipgroup(ii)=idcgroup(ii)
pfinal(ii)=dcfinal(ii)
i2pvalue(ii)=ipvalue(ii)
enddo
do ii=1,nmothers(i)
do jj=1,3
i2daughters(i,ii,jj)=idaughters(i,ii,jj)
enddo
enddo
c print *,'Part. ids:',(idcid(ii),ii=1,npart)
enddo ! i
c print *,'Resulting particle ids:'
c print *,(ipid(ii),ii=1,npart)
cC Set new groups with the right order
c igroup=0
c npar=0
c do i=1,npart
c if(ipgroup(i).eq.0) cycle
c if(i.eq.1.and.idcgroup(i).ne.igroup)then
c npar=1
c igroup=igroup+10**(8-npar)
c idcgroup(i)=igroup
c cycle
c endif
c if(ipgroup(i).eq.ipgroup(i-1))then
c idcgroup(i)=igroup
c else if(izeroes(ipgroup(i)).lt.izeroes(ipgroup(i-1)))then
c npar=npar+1
c igroup=igroup+10**(8-npar)
c idcgroup(i)=igroup
c else if(izeroes(ipgroup(i)).eq.izeroes(ipgroup(i-1)))then
c igroup=igroup+10**(8-npar)
c idcgroup(i)=igroup
c else
cc print *,'igroup,ipgroup(i):',igroup,ipgroup(i)
c do while(izeroes(igroup).lt.izeroes(ipgroup(i)))
cc print *,'nzeroes: ',nzeroes(igroup),8-npar+1
c do while(nzeroes(igroup).lt.8-npar+1)
c igroup=igroup-10**(8-npar)
c enddo
c npar=npar-1
c enddo
c igroup=igroup+10**(8-npar)
c idcgroup(i)=igroup
cc print *,'idcgroup,ipgroup:',idcgroup(i),ipgroup(i)
c endif
c enddo
end
logical function DupProcess(idum)
c*********************************************************************
c Checks to see if a process has been already calculated
c Current version does NOT check for matching coupling orders
c*********************************************************************
implicit none
c
c Constants
c
include "params.inc"
integer ndcmax
parameter(ndcmax=20)
integer maxsubproc
parameter (MaxSubProc=9999)
c
c Arguments
c
integer idum !not used, inputs come from common block
c
c Local
c
integer nproc
integer ndcpart,idcid(ndcmax),idcgroup(ndcmax)
logical dcfinal(ndcmax)
integer sv_ndcpart(MaxSubProc),sv_idcid(ndcmax,MaxSubProc)
integer sv_incoming(0:2,MaxSubProc),sv_names(MaxSubProc)
integer qonium(MaxSubProc)
integer i,iproc,ipart
logical foundmatch
c
c Global
c
integer iline(-maxlines:maxlines),idir(-maxlines:maxlines)
integer this_coup(max_coup) ,goal_coup(max_coup)
common/to_proc/iline,idir,this_coup,goal_coup
integer nincoming,nincfirst
common/to_proc2/nincoming,nincfirst
integer nameprefix
common/to_multiname/nameprefix
data nproc/0/
save sv_ndcpart,sv_incoming
c
c function
c
integer get_tag_onium
external get_tag_onium
include "onia.inc"
c-----
c Begin Code
c-----
call OrderParticles(ndcpart,idcid,idcgroup,dcfinal)
iproc = 1
foundmatch = .false.
do while (iproc .le. nproc .and. .not. foundmatch)
c
c First check initial state particles
c
if(nameprefix .ne. sv_names(iproc))then
iproc = iproc+1
cycle
endif
foundmatch = (nincoming .eq. sv_incoming(0,iproc))
ipart = 0
do while (foundmatch .and. ipart .lt. nincoming)
ipart = ipart+1
foundmatch = (iline(ipart) .eq. sv_incoming(ipart,iproc))
enddo
c
c Now check final state particles
c
foundmatch = (ndcpart .eq. sv_ndcpart(iproc) .and. foundmatch)
ipart = 0
do while (foundmatch .and. ipart .lt. ndcpart)
ipart = ipart+1
foundmatch = (idcid(ipart) .eq. sv_idcid(ipart,iproc))
enddo
if (.not. foundmatch) then
c write(*,*) "Failed imatch",iproc,ipart,idcid(ipart),sv_idcid(ipart,iproc)
endif
c
c PA: Here we have to do additional an check in case of onium state
c
foundmatch=(get_tag_onium(S_qn,L_qn,J_qn,C_qn)
& .eq.qonium(iproc).and.foundmatch)
iproc = iproc+1
enddo
if (foundmatch) then
write(*,*) "Found match",iproc,nproc
write(*,'(25i5)') (idcid(i),i=1,ndcpart)
write(*,'(25i5)') (sv_idcid(i,iproc),i=1,ndcpart)
else
nproc = nproc+1
write(*,*) "New Process",nproc
write(*,'(25i5)') (idcid(i),i=1,ndcpart)
do i=1,ndcpart
sv_idcid(i,nproc) = idcid(i)
enddo
sv_names(nproc) = nameprefix
c
c PA: add info on onium
qonium(nproc)=get_tag_onium(S_qn,L_qn,J_qn,C_qn)
c
sv_ndcpart(nproc) = ndcpart
sv_incoming(0,nproc) = nincoming
do ipart=1,nincoming
sv_incoming(ipart,nproc)=iline(ipart)
enddo
endif
dupprocess = foundmatch
end
subroutine trimspace(str,maxlen)
implicit none
character*(*) str
integer maxlen,i,j
j=len_trim(str(1:maxlen))
i=index(str(1:j),' ')
do while(i.gt.0)
str = str(1:i-1)//str(i+1:j)
j=j-1
i=index(str(1:j),' ')
enddo
return
end
subroutine no_spaces(buff,nchars)
c**********************************************************************
c Given buff a buffer of words separated by spaces
c returns it where all space are moved to the right
c returns also the length of the single word.
c maxlength is the length of the buffer
c AUTHOR: FABIO MALTONI
c**********************************************************************
implicit none
c
c Constants
c
integer maxline
parameter (maxline=80)
character*1 null
parameter (null=' ')
c
c Arguments
c
character*(maxline) buff
integer nchars,maxlength
c
c Local
c
integer i,j
character*(maxline) temp
c-----
c Begin Code
c-----
nchars=0
c write (*,*) "buff=",buff(1:maxlength)
do i=1,maxline
if(buff(i:i).ne.null) then
nchars=nchars+1
temp(nchars:nchars)=buff(i:i)
endif
c write(*,*) i,":",buff(1:maxlength),":",temp(1:nchars),":"
enddo
buff=temp
end
integer function get_tag_onium(S_qn,L_qn,J_qn,C_qn)
c
c this function tags th onium state with the use of prime numbers
c (PA)
c
c arguments
c
integer S_qn,L_qn,J_qn,C_qn
c---
cBegin code
c---
if (C_qn.gt.0) then
c
if(S_qn.eq.0) then
get_tag_onium=2
elseif (S_qn.eq.1) then
get_tag_onium=3
endif
c
if(L_qn.eq.0) then
get_tag_onium=get_tag_onium*5
elseif (L_qn.eq.1) then
get_tag_onium=get_tag_onium*7
endif
c
if(J_qn.eq.0) then
get_tag_onium=get_tag_onium*11
elseif (J_qn.eq.1) then
get_tag_onium=get_tag_onium*13
elseif (J_qn.eq.2) then
get_tag_onium=get_tag_onium*17
endif
c
if(C_qn.eq.1) then
get_tag_onium=get_tag_onium*19
elseif (C_qn.eq.8) then
get_tag_onium=get_tag_onium*21
endif
c
else
get_tag_onium=0
endif
return
end
|
c*********************************************************************
function urand()
c=====================================================================
c Return the next pseudo-random deviate from a sequence which is
c uniformly distributed in the interval [0,1]
c
c Uses the function ran0, the "minimal standard" random number
c generator of Park and Miller (Comm. ACM 31, 1192-1201, Oct 1988;
c Comm. ACM 36 No. 7, 105-110, July 1993).
c=====================================================================
implicit none
c
c Input - none
c
c Output
double precision urand
c
c Local
integer iseed
double precision ran0
external ran0
c
c Common block to make iseed visible to rninit (and to save
c it between calls)
common /rnseed/ iseed
c
urand = ran0( iseed )
return
end
c*********************************************************************
subroutine rninit( seed )
c=====================================================================
c Initialize random number generator urand with given seed
c=====================================================================
implicit none
c
c Input
integer seed
c
c Output - none
c
c Local
integer iseed
c
c Common block to communicate with urand
common /rnseed/ iseed
c
c Set the seed value
iseed = seed
if(iseed.le.0) iseed=123456
return
end
c*********************************************************************
function ran0( seed )
c=====================================================================
c "Minimal standard" pseudo-random number generator of Park and
c Miller. Returns a uniform random deviate r s.t. 0 < r < 1.0.
c Set seed to any non-zero integer value to initialize a sequence,
c then do not change seed between calls for successive deviates
c in the sequence.
c
c References:
c Park, S. and Miller, K., "Random Number Generators: Good Ones
c are Hard to Find", Comm. ACM 31, 1192-1201 (Oct. 1988)
c Park, S. and Miller, K., in "Remarks on Choosing and Imple-
c menting Random Number Generators", Comm. ACM 36 No. 7,
c 105-110 (July 1993)
c=====================================================================
c *** Declaration section ***
c
implicit none
c
c Input/Output:
integer seed
c
c Output:
double precision ran0
c
c Constants:
integer A,M,Q,R
parameter (A=48271,M=2147483647,Q=44488,R=3399)
double precision SCALE,EPS,RNMX
parameter (SCALE=1./M,EPS=1.2e-7,RNMX=1.-EPS)
c
c Local:
integer j
c
c *** Executable section ***
c
j = seed/Q
seed = A*(seed-j*Q)-R*j
if (seed .lt. 0) seed = seed+M
ran0 = min(seed*SCALE,RNMX)
return
end
|
c RINGFIT.FOR - a program used to solve for the
c rings of the fabry-perot interferometer. this is done by
c solving the equation:
c
c wl= (a + b*z ) * cos( arctan( r/c ) )
c
c where a, b, and c are the coefficients to be solved for and
c r is the radius of a calibration ring, wl is the wavelength
c of that ring, z is the instrumental offset of the capacitor
c in the f-p etalon which allows tuning the passband of the
c etalon. the coeffecients are found by a least-squares fit
c which inverts the above equation and solves for a, b, and c.
c this is equivalent to the dispersion solution for a long-slit
c spectrograph.
c
c re-written: 5 june 1986 t.williams
c
c modified for incorporation into iraf
c 15 july 1987 g. jacoby
c
subroutine rngfit (alam, z, r, num, old, error, sigma)
real*4 sum(4,4),old(3),q(3),new(3),save(3),error(3)
real*4 alam(1),r(1),z(1)
integer num
logical con
data conv,itmax /1.0e-06,25/
c
c do the least-squares fit - a first guess must be stored in old
c
do 6000 iter=1,itmax
do 2000 i=1,4
do 1000 j=1,4
sum(i,j) = 0.0
1000 continue
2000 continue
sumysq = 0.0
do 4000 i=1,num
ang = atan2 (r(i),old(3))
fac = old(1) + old(2) * z(i)
err = alam(i) - fac * cos(ang)
q(1) = cos(ang)
q(2) = z(i) * q(1)
q(3) = r(i) * fac * sin(ang) / (old(3)*old(3) + r(i)*r(i))
sumysq = sumysq + err * err
do 3500 j=1,3
sum (j,4) = sum(j,4) + err * q(j)
do 3000 k=1,3
sum(j,k) = sum(j,k) + q(j) * q(k)
3000 continue
3500 continue
4000 continue
do 4500 i=1,3
save(i) = sum(i,4)
4500 continue
det = simul(3,sum,new,1.0e-10,0,4)
con = .true.
do 5000 i=1,3
if (abs(new(i)/old(i)).gt.conv) con = .false.
old(i) = old(i) + new(i)
5000 continue
if (con) go to 40
6000 continue
40 do 6500 i=1,3
sumysq = sumysq - new(i) * save(i)
6500 continue
denom = (num-3)
if(denom.le.0) denom=1.0
sigma = sqrt(sumysq/(denom))
do 7000 i=1,3
error(i) = sigma * sqrt(sum(i,i))
7000 continue
c
return
end
c-----------------------------------------------------------------
subroutine rngft0 (alam, z, r, old)
c
c make an initial guess at the coefficients of the ring
c
real alam(*), r(*), z(*), old(*)
old(3) = 2833.0
cos1 = cos(atan2(r(1),old(3)))
cos2 = cos(atan2(r(2),old(3)))
old(2) = (alam(1)/cos1 - alam(2)/cos2) / (z(1) - z(2))
old(1) = alam(1) / cos1 - old(2) * z(1)
return
end
|
SUBROUTINE h_fill_fpp(ABORT,err)
*--------------------------------------------------------
* Hall C HMS Focal Plane Polarimeter Code
*
* Purpose: fill FPP histograms
* histogram IDs are from common block in file
* hms_id_histid.cmn and assigned in h_init_histid
*
* Created by Frank R. Wesselmann, February 2004
*
*--------------------------------------------------------
IMPLICIT NONE
INCLUDE 'hms_data_structures.cmn'
INCLUDE 'hms_id_histid.cmn'
include 'gen_detectorids.par'
include 'gen_decode_common.cmn'
INCLUDE 'hms_fpp_params.cmn'
INCLUDE 'hms_fpp_event.cmn'
INCLUDE 'hms_geometry.cmn'
INCLUDE 'hms_statistics.cmn'
character*10 here
parameter (here= 'h_fill_fpp')
integer*4 rad2deg
parameter (rad2deg=57.29578)
logical ABORT
character*(*) err
integer*4 DCset,iChamber,iLayer,iPlane,iWire,iHit,hit2,tdc,iTrack
integer*4 iCluster, Nraw, iRaw,hid,hid1,hid2, iROC, ii
real*4 dist,time, istat
ABORT= .FALSE.
err= ' '
* * check if we have any work to do
if (HFPP_raw_tot_hits .le. 0) RETURN
* * for each ROC, histogram TDC value of trigger reference
hid = hidFPP_tdcROC
do ii=0,G_DECODE_MAXROCS
iROC = HFPP_my_ROCs(ii)
if (iROC.lt.0) EXIT !end of list
call hf2(hid,float(iROC),float(HFPP_trigger_TDC(iROC)),1.)
enddo !ii
* * for each plane, histogram all TDC values seen
do iHit=1, HFPP_raw_tot_hits
iPlane = HFPP_raw_plane(iHit)
iWire = HFPP_raw_wire(iHit)
tdc = HFPP_raw_TDC(iHit)
if (iPlane.le.H_FPP_N_PLANES) then
hid = hidFPP_tdc(iPlane)
call hf2(hid,float(tdc),float(iWire),1.)
endif
enddo
* * for each plane, wire, histogram all hit times seen
do iHit=1, HFPP_raw_tot_hits
iPlane = HFPP_raw_plane(iHit)
iWire = HFPP_raw_wire(iHit)
time = HFPP_HitTime(iHit)
if (iPlane.le.H_FPP_N_PLANES) then
hid = hidFPP_alltimes(iPlane)
call hf2(hid,time,float(iWire),1.)
endif
enddo
* * for each plane, wire, histogram times of first hit seen
do iPlane=1,H_FPP_N_PLANES
hid1 = hidFPP_planetime(iPlane)
hid2 = hidFPP_time1(iPlane)
do iWire=1,HFPP_Nwires(iPlane)
iHit = HFPP_hit1idx(iPlane,iWire)
if (iHit.gt.0) then
time = HFPP_HitTime(iHit)
call hf1(hid1,time,1.)
call hf2(hid2,time,float(iWire),1.)
endif
enddo
enddo
* * for each plane, wire, histogram time difference between 1st and 2nd hit seen
do iPlane=1,H_FPP_N_PLANES
do iWire=1,HFPP_Nwires(iPlane)
hit2 = HFPP_hit2idx(iPlane,iWire)
if (hit2.gt.0) then
iHit = HFPP_hit1idx(iPlane,iWire)
time = HFPP_HitTime(hit2) - HFPP_HitTime(iHit)
hid = hidFPP_time12(iPlane)
call hf2(hid,time,float(iWire),1.)
endif
enddo
enddo
* * for each plane, wire, histogram size of clusters
do DCset=1,H_FPP_N_DCSETS
do iChamber=1,H_FPP_N_DCINSET
do iLayer=1,H_FPP_N_DCLAYERS
iPlane = H_FPP_N_DCLAYERS * H_FPP_N_DCINSET * (DCset-1)
> + H_FPP_N_DCLAYERS * (iChamber-1)
> + iLayer
hid1 = hidFPP_rawinclust(iPlane)
hid2 = hidFPP_rate1(iPlane)
do iCluster=1,HFPP_nClusters(DCset,iChamber,iLayer)
Nraw = HFPP_nHitsinCluster(DCset,iChamber,iLayer,iCluster)
call hf1(hid1,float(Nraw),1.) !number of raw in cluster
do iRaw=1,Nraw
iHit = HFPP_Clusters(DCset,iChamber,iLayer,iCluster,iRaw)
iWire = HFPP_raw_wire(iHit)
call hf1(hid2,float(iWire),1.) !hit rate per wire
enddo !iRaw
enddo !iCluster
enddo !iLayer
enddo !iChamber
enddo !DCset
* * for each DCset,iChamber,iLayer, histogram in-layer distance betw hit wires and HMS track
do DCset=1,H_FPP_N_DCSETS
do iChamber=1,H_FPP_N_DCINSET
do iLayer=1,H_FPP_N_DCLAYERS
hid = hid_HMSwire(DCset,iChamber,iLayer)
if (HFPP_nClusters(DCset,iChamber,iLayer).gt.0) then
do iCluster=1,HFPP_nClusters(DCset,iChamber,iLayer)
do iHit=1,HFPP_nHitsinCluster(DCset,iChamber,iLayer,iCluster)
iRaw = HFPP_Clusters(DCset,iChamber,iLayer,iCluster,iHit)
iWire = HFPP_raw_wire(iRaw)
dist = HFPP_dHMS(DCset,iChamber,iLayer,iCluster,iHit)
call hf2(hid,dist,float(iWire),1.)
enddo !iHit
enddo !iCluster
endif
enddo !iLayer
enddo !iChamber
enddo !DCset
* * for each DCset,iChamber,iLayer, histogram drift distances
do DCset=1,H_FPP_N_DCSETS
do iChamber=1,H_FPP_N_DCINSET
do iLayer=1,H_FPP_N_DCLAYERS
iPlane = H_FPP_N_DCLAYERS * H_FPP_N_DCINSET * (DCset-1)
> + H_FPP_N_DCLAYERS * (iChamber-1)
> + iLayer
hid1 = hidFPP_driftT(DCset,iChamber,iLayer)
hid2 = hidFPP_driftX(DCset,iChamber,iLayer)
if (HFPP_nClusters(DCset,iChamber,iLayer).gt.0) then
do iCluster=1,HFPP_nClusters(DCset,iChamber,iLayer)
do iHit=1,HFPP_nHitsinCluster(DCset,iChamber,iLayer,iCluster)
iRaw = HFPP_Clusters(DCset,iChamber,iLayer,iCluster,iHit)
iWire = HFPP_raw_wire(iRaw)
time = HFPP_drift_time(DCset,iChamber,iLayer,iWire)
dist = HFPP_drift_dist(DCset,iChamber,iLayer,iWire)
call hf2(hid1,time,float(iWire),1.)
call hf2(hid2,dist,float(iWire),1.)
enddo !iHit
enddo !iCluster
endif
enddo !iLayer
enddo !iChamber
enddo !DCset
* * for each DCset, histogram simple (Nick's) efficiency:
* * if 5+ layers of set have hit, mark all layers (in) efficient
* * if the do (not) have a hit
do DCset=1,H_FPP_N_DCSETS
if (HFPP_Nlayershit_set(DCset).ge.(H_FPP_N_DCINSET*H_FPP_N_DCLAYERS-1)) then
hid = hidFPP_NickEff(DCset)
do iChamber=1,H_FPP_N_DCINSET
do iLayer=1,H_FPP_N_DCLAYERS
iPlane = H_FPP_N_DCLAYERS * H_FPP_N_DCINSET * (DCset-1)
> + H_FPP_N_DCLAYERS * (iChamber-1)
> + iLayer
ii = H_FPP_N_DCLAYERS * (iChamber-1)
> + iLayer
if (HFPP_N_planehits(iPlane) .gt. 0) then
call hf1(hid,float(ii),1.)
else
call hf1(hid,float(ii),0.)
endif
enddo !iLayer
enddo !iChamber
endif
enddo !DCset
* * for each DCset,iChamber,iLayer, histogram expected hits and actual
do DCset=1,H_FPP_N_DCSETS
do iChamber=1,H_FPP_N_DCINSET
do iLayer=1,H_FPP_N_DCLAYERS
hid1 = hidFPP_should(DCset,iChamber,iLayer)
hid2 = hidFPP_did(DCset,iChamber,iLayer)
do iTrack=1,HFPP_N_tracks(DCset)
iWire = HFPP_stat_shouldhit(DCset,iChamber,iLayer,iTrack)
if (HFPP_stat_diddhit(DCset,iChamber,iLayer,iTrack)) then
istat = 1.0
else
istat = 0.0
endif
call hf1(hid1,float(iWire),1.) ! expected hit frequency
call hf1(hid2,float(iWire),istat) ! hit efficiency
enddo !iTrack
enddo !iLayer
enddo !iChamber
enddo !DCset
* * for each DCset,iChamber,iLayer, histogram min distance betw hits and track
do DCset=1,H_FPP_N_DCSETS
hid = hidFPP_dist(DCset)
do iChamber=1,H_FPP_N_DCINSET
do iLayer=1,H_FPP_N_DCLAYERS
ii = H_FPP_N_DCLAYERS * (iChamber-1) + iLayer
do iTrack=1,HFPP_N_tracks(DCset)
dist = HFPP_stat_dist2closest(DCset,iChamber,iLayer,iTrack)
call hf2(hid,float(ii),dist,1.)
enddo !iTrack
enddo !iLayer
enddo !iChamber
enddo !DCset
* * for each DCset,iChamber,iLayer, histogram linear and angular resolutions
if (HFPP_calc_resolution.ne.0) then
do DCset=1,H_FPP_N_DCSETS
hid1 = hidFPP_resol_lin(DCset)
hid2 = hidFPP_resol_ang(DCset)
do iChamber=1,H_FPP_N_DCINSET
do iLayer=1,H_FPP_N_DCLAYERS
ii = H_FPP_N_DCLAYERS * (iChamber-1) + iLayer
do iTrack=1,HFPP_N_tracks(DCset)
call hf2(hid1,float(ii),HFPP_track_resolution(DCset,iChamber,iLayer,iTrack),1.)
call hf2(hid2,float(ii),HFPP_track_angresol(DCset,iChamber,iLayer,iTrack),1.)
enddo !iTrack
enddo !iLayer
enddo !iChamber
enddo !DCset
endif
* * for each track in each set, track chi**2, mx,bx,my,by, # hits, HFPP_track_fine,
* * sclose,zclose,theta,phi
do DCset=1,H_FPP_N_DCSETS
call hf1(hidFPP_Ntrk(DCset),float(HFPP_N_tracks(DCset)),1.)
do iTrack=1,HFPP_N_tracks(DCset)
call hf1(hidFPP_Nhitontrk(DCset),float(HFPP_track_Nlayers(DCset,iTrack)),1.)
call hf1(hidFPP_Nrawontrk(DCset),float(HFPP_track_Nhits(DCset,iTrack)),1.)
call hf1(hidFPP_trk_chi2(DCset),HFPP_track_chi2(DCset,iTrack),1.)
call hf1(hidFPP_trk_mx(DCset),HFPP_track_dx(DCset,iTrack),1.) !fp coords
call hf1(hidFPP_trk_bx(DCset),HFPP_track_x(DCset,iTrack),1.)
call hf1(hidFPP_trk_my(DCset),HFPP_track_dy(DCset,iTrack),1.)
call hf1(hidFPP_trk_by(DCset),HFPP_track_y(DCset,iTrack),1.)
call hf1(hidFPP_fine_mx(DCset),HFPP_track_fine(DCset,iTrack,1),1.) !chamber coords
call hf1(hidFPP_fine_bx(DCset),HFPP_track_fine(DCset,iTrack,2),1.)
call hf1(hidFPP_fine_my(DCset),HFPP_track_fine(DCset,iTrack,3),1.)
call hf1(hidFPP_fine_by(DCset),HFPP_track_fine(DCset,iTrack,4),1.)
call hf1(hidFPP_sclose(DCset),HFPP_track_sclose(DCset,iTrack),1.)
call hf1(hidFPP_zclose(DCset),HFPP_track_zclose(DCset,iTrack),1.)
call hf1(hidFPP_thetapol(DCset),HFPP_track_theta(DCset,iTrack),1.)
call hf1(hidFPP_phipol(DCset),HFPP_track_phi(DCset,iTrack),1.)
enddo !iTrack
enddo !DCset
RETURN
END
|
SUBROUTINE IMSEL (INDSK, INCNO, OUTDSK, OUTCNO, VERS, INCB, OUTCB,
* INLUN, OUTLUN, BPOL, EPOL, BIF, EIF, FREQID, START, FINISH,
* NUMSRC, SOURCS, ANTENS, NUMANT, INSUB, OUTSUB, INBUF, OUTBUF,
* IRET)
C-----------------------------------------------------------------------
C! Copies an IM table with data selection
C# EXT-appl Calibration
C-----------------------------------------------------------------------
C; Copyright (C) 1995-2000, 2011
C; Associated Universities, Inc. Washington DC, USA.
C;
C; This program is free software; you can redistribute it and/or
C; modify it under the terms of the GNU General Public License as
C; published by the Free Software Foundation; either version 2 of
C; the License, or (at your option) any later version.
C;
C; This program is distributed in the hope that it will be useful,
C; but WITHOUT ANY WARRANTY; without even the implied warranty of
C; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
C; GNU General Public License for more details.
C;
C; You should have received a copy of the GNU General Public
C; License along with this program; if not, write to the Free
C; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
C; MA 02139, USA.
C;
C; Correspondence concerning AIPS should be addressed as follows:
C; Internet email: aipsmail@nrao.edu.
C; Postal address: AIPS Project Office
C; National Radio Astronomy Observatory
C; 520 Edgemont Road
C; Charlottesville, VA 22903-2475 USA
C-----------------------------------------------------------------------
C Copies data from selected IFs that lie within a specified time
C range from one interferometer model (IM) table to another. Data may
C also be filtered using the source ID, subarray number, or antenna
C number.
C
C If FREQID is positive then only data for frequency ID FREQID or
C frequency ID zero will be copied to the output table and these data
C will be assigned frequency ID 1. If FREQID is not positive then data
C will not be restricted by frequency ID and frequency IDs will be
C unchanged in the output table.
C
C If NUMSRC is positive then only data for sources listed in the
C first NUMSRC elements of SOURCS or for source ID zero will be copied
C to the output table. If NUMSRC is not positive then data will not be
C restricted by source.
C
C If NUMANT is positive then only data for antennas listed in the
C first NUMANT elements of ANTENS or for antenna number zero will be
C copied to the output table. If NUMANT is not positive then data will
C not be restricted by antenna.
C
C If INSUB is positive then only data for subarray INSUB or subarray
C zero will be copied to the output table. If INSUB is not positive
C then data will not be restricted by subarray.
C
C If OUTSUB is positive then all data written to the output table
C will be assigned to subarray OUTSUB. If OUTSUB is not positive then
C subarray numbers will not be changed in the output table.
C
C Writes an informational message at priority level 3 if the data are
C copied successfully. Writes at least one error message at priority
C level 6 or higher if the data are not copied successfully.
C
C The input and output tables must be attached to different files.
C
C Inputs:
C INDSK I Disk number for input table
C INCNO I Catalogue number for input table
C OUTDSK I Disk number for output table
C OUTCNO I Catalogue number for output table
C VERS I Version number of input and output tables; if
C 0 the highest version number of an IM table
C attached to the input file will be used
C INCB I(256) Catalogue block of parent data file for
C the input table
C INLUN I AIPS LUN used for input table
C OUTLUN I AIPS LUN used for output table
C BIF I Lowest numbered IF to copy
C EIF I Highest numbered IF to copy
C FREQID I Selected frequency ID (see above)
C START D Earliest time to copy (days)
C FINISH D Latest time to copy (days)
C NUMSRC I Number of sources selected (see above)
C SOURCS I(*) List of source IDs selected (see above)
C ANTENS I(*) List of antenna numbers selected
C NUMANT I Number of antennas selected (see above)
C INSUB I Subarray number selected (see above)
C OUTSUB I Output subarray number (see above)
C
C Input/Output:
C OUTCB I(256) Catalogue block of parent data file for
C the output table
C INBUF I(512) Buffer for input table
C OUTBUF I(512) Buffer for output table
C
C Output:
C IRET I Return status:
C 0 if selected data copied;
C non-zero if not all data copied
C-----------------------------------------------------------------------
INTEGER INDSK, INCNO, OUTDSK, OUTCNO, VERS, INCB(256),
* OUTCB(256), INLUN, OUTLUN, BPOL, EPOL, BIF, EIF, FREQID,
* NUMSRC, SOURCS(*), ANTENS(*), NUMANT, INSUB, OUTSUB, INBUF(*),
* OUTBUF(*), IRET
DOUBLE PRECISION START, FINISH
C
INCLUDE 'INCS:PUVD.INC'
C
C Local variables:
C
C INVER input table version number
C INROW input table row number
C INCIDX input row column index array
C INCDIM input row column dimensions array
C OBSCOD observing code
C RDATE reference date
C NUMSTK number of Stokes parameters
C STK1 first Stokes parameter code
C INNIF number of IFs in input table
C NUMCHN number of channels
C REFFRQ reference frequency
C CHANBW channel bandwidth
C REFPIX reference pixel on frequency axis
C NUMPOL number of polarizations in table
C NUMPLY number of polynomial terms in table
C CORREV correlator software revision code
C
C NUMROW number of rows in input table
C
C LOIF first IF to copy
C HIIF last IF to copy
C OUTNIF number of IFs to copy
C
C REFORM is output data reformatted rather than copied?
C
C OUTVER output table version number
C OUTROW output row number
C OUCIDX output column index array
C OUCDIM output column dimensions array
C
C ROW number of rows from input file examined so far
C
C MAXPLY maximum number of terms in delay rate polynomials
C
C TIME reference time of current row
C TIMINT time interval covered by current row
C SOURID source ID of current row
C ANTNUM antenna number of current row
C SUBARR subarray number of current row
C FQID frequency ID of current row
C IFR ionospheric Faraday rotation
C INFVR input frequency offsets
C INPD input phase delay polynomials
C GDELAY group delay polynomials
C INPR input phase rate polynomials
C GRATE group rate polynomials
C DISP dispersive delay
C DDISP rate of change of dispersive delay
C
C SRCSEL is current source selected?
C ANTSEL is current antenna selected?
C SRC index into SOURCS
C ANT index into ANTENS
C
C POL polarization index
C INBND input band index
C OUTBND output band index
C TERM polynomial term
C OUTFVR output frequency offsets
C OUTPD output phase delay polynomials
C OUTPR output phase rate polynomials
C
C IRET1 disposable return status
C
INTEGER INVER
INTEGER INROW
INTEGER INCIDX(20)
INTEGER INCDIM(20)
CHARACTER OBSCOD*8
CHARACTER RDATE*8
INTEGER NUMSTK
INTEGER STK1
INTEGER INNIF
INTEGER NUMCHN
DOUBLE PRECISION REFFRQ
DOUBLE PRECISION CHANBW
DOUBLE PRECISION REFPIX
INTEGER NUMPOL
INTEGER NUMPLY
DOUBLE PRECISION CORREV
C
INTEGER NUMROW
C
INTEGER LOIF
INTEGER HIIF
INTEGER OUTNIF
C
LOGICAL REFORM
C
INTEGER OUTVER
INTEGER OUTROW
INTEGER OUCIDX(20)
INTEGER OUCDIM(20)
C
INTEGER ROW
C
INTEGER MAXPLY
PARAMETER (MAXPLY = 20)
C
DOUBLE PRECISION TIME
REAL TIMINT
INTEGER SOURID
INTEGER ANTNUM
INTEGER SUBARR
INTEGER FQID
REAL IFR
REAL INFVR(MAXIF)
DOUBLE PRECISION INPD(2, MAXIF, MAXPLY)
DOUBLE PRECISION GDELAY(2, MAXPLY)
DOUBLE PRECISION INPR(2, MAXIF, MAXPLY)
DOUBLE PRECISION GRATE(2, MAXPLY)
REAL DISP
REAL DDISP
C
LOGICAL SRCSEL
LOGICAL ANTSEL
INTEGER SRC
INTEGER ANT
C
INTEGER POL, LBPOL, NEWPOL, K
INTEGER INBND
INTEGER OUTBND
INTEGER TERM
REAL OUTFVR(MAXIF)
DOUBLE PRECISION OUTPD(2, MAXIF, MAXPLY)
DOUBLE PRECISION OUTPR(2, MAXIF, MAXPLY)
C
INTEGER IRET1
C
INCLUDE 'INCS:DMSG.INC'
C-----------------------------------------------------------------------
INVER = VERS
CALL IMINIT ('READ', INBUF, INDSK, INCNO, INVER, INCB, INLUN,
* INROW, INCIDX, INCDIM, OBSCOD, RDATE, NUMSTK, STK1, INNIF,
* NUMCHN, REFFRQ, CHANBW, REFPIX, NUMPOL, NUMPLY, CORREV, IRET)
IF (IRET.EQ.0) THEN
NUMROW = INBUF(5)
C Set IF range:
LOIF = MAX (1, BIF)
HIIF = MIN (INNIF, EIF)
OUTNIF = HIIF - LOIF + 1
IF (OUTNIF.LE.0) THEN
OUTNIF = INNIF
LOIF = 1
END IF
C set pol range
LBPOL = MAX (1, BPOL)
NEWPOL = MIN (2, MIN (NUMPOL, EPOL)) - LBPOL + 1
IF (NEWPOL.LE.0) THEN
NEWPOL = NUMPOL
LBPOL = 1
END IF
REFORM = (OUTNIF.NE.INNIF) .OR. (NEWPOL.NE.NUMPOL)
C
OUTVER = INVER
CALL IMINIT ('WRIT', OUTBUF, OUTDSK, OUTCNO, OUTVER, OUTCB,
* OUTLUN, OUTROW, OUCIDX, OUCDIM, OBSCOD, RDATE, NUMSTK, STK1,
* OUTNIF, NUMCHN, REFFRQ, CHANBW, REFPIX, NEWPOL, NUMPLY,
* CORREV, IRET)
IF (IRET.EQ.0) THEN
ROW = 0
C
C Invariant: IRET = 0 implies that selected data from the
C first ROW rows of the input table has been
C written to the output table and REFORM = false
C implies that all of the data in the first ROW
C rows has been copied
C Bound: NUMROW - ROW when IRET = 0; 0 otherwise
C
10 IF ((IRET.EQ.0) .AND. (ROW.NE.NUMROW)) THEN
INROW = ROW + 1
CALL TABIM ('READ', INBUF, INROW, INCIDX, INCDIM, NUMPOL,
* TIME, TIMINT, SOURID, ANTNUM, SUBARR, FQID, IFR,
* INFVR, INPD, GDELAY, INPR, GRATE, DISP, DDISP, IRET)
IF (IRET.EQ.0) THEN
C check source
IF ((NUMSRC.GT.0) .AND. (SOURID.NE.0)) THEN
SRCSEL = .FALSE.
DO 20 SRC = 1,NUMSRC
IF (SOURCS(SRC).EQ.SOURID) SRCSEL = .TRUE.
20 CONTINUE
ELSE
SRCSEL = .TRUE.
END IF
C check ant
IF ((NUMANT.GT.0) .AND. (ANTNUM.NE.0)) THEN
ANTSEL = .FALSE.
DO 30 ANT = 1,NUMANT
IF (ANTENS(ANT).EQ.ANTNUM) ANTSEL = .TRUE.
30 CONTINUE
ELSE
ANTSEL = .TRUE.
END IF
C
IF ((START.LE.TIME) .AND. (TIME.LE.FINISH) .AND.
* ((FREQID.LE.0) .OR. (FQID.EQ.0) .OR.
* (FQID.EQ.FREQID)) .AND. SRCSEL .AND. ANTSEL .AND.
* ((INSUB.LE.0) .OR. (SUBARR.LE.0) .OR.
* (SUBARR.EQ.INSUB))) THEN
C
C This record is selected so copy the data to
C the output table:
C
DO 60 POL = 1,NEWPOL
K = POL + LBPOL - 1
DO 50 INBND = LOIF, HIIF
OUTBND = INBND - LOIF + 1
OUTFVR(OUTBND) = INFVR(INBND)
DO 40 TERM = 1,NUMPLY
OUTPD(POL,OUTBND,TERM) =
* INPD(K,INBND,TERM)
OUTPR(POL,OUTBND,TERM) =
* INPR(K,INBND,TERM)
40 CONTINUE
50 CONTINUE
60 CONTINUE
IF (FREQID.GT.0) FQID = 1
IF (OUTSUB.GT.0) SUBARR = OUTSUB
CALL TABIM ('WRIT', OUTBUF, OUTROW, OUCIDX, OUCDIM,
* NEWPOL, TIME, TIMINT, SOURID, ANTNUM, SUBARR,
* FQID, IFR, OUTFVR, OUTPD, GDELAY, OUTPR, GRATE,
* DISP, DDISP, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT, 9060) IRET
CALL MSGWRT (6)
END IF
C This record is not selected so output table will
C not be an exact copy of the input table.
ELSE
REFORM = .TRUE.
END IF
C This record is flagged and will not be copied so the
C output table will not be an exact copy of the input
C table.
ELSE IF (IRET.LT.0) THEN
REFORM = .TRUE.
IRET = 0
C read failed
ELSE
WRITE (MSGTXT, 9061) IRET
CALL MSGWRT (6)
END IF
C
ROW = ROW + 1
GO TO 10
END IF
C
CALL TABIM ('CLOS', OUTBUF, OUTROW, OUCIDX, OUCDIM, NEWPOL,
* TIME, TIMINT, SOURID, ANTNUM, SUBARR, FQID, IFR, OUTFVR,
* OUTPD, GDELAY, OUTPR, GRATE, DISP, DDISP, IRET1)
IF (IRET1.NE.0) THEN
WRITE (MSGTXT, 9062) IRET1
CALL MSGWRT (6)
IRET = IRET1
END IF
C failed to open output table
ELSE
WRITE (MSGTXT, 9063) IRET
CALL MSGWRT (6)
END IF
C
CALL TABIM ('CLOS', INBUF, INROW, INCIDX, INCDIM, NUMPOL, TIME,
* TIMINT, SOURID, ANTNUM, SUBARR, FQID, IFR, INFVR,
* INPD, GDELAY, INPR, GRATE, DISP, DDISP, IRET1)
IF (IRET1.NE.0) THEN
WRITE (MSGTXT, 9064) IRET1
CALL MSGWRT (6)
IRET = IRET1
END IF
ELSE
C
C Failed to open input table
C
WRITE (MSGTXT, 9065) IRET
CALL MSGWRT (6)
END IF
C
IF (IRET.EQ.0) THEN
C
C Issue summary message:
C
IF (REFORM) THEN
WRITE (MSGTXT, 1060) INDSK, INCNO, INVER, OUTDSK, OUTCNO,
* OUTVER
ELSE
WRITE (MSGTXT, 1061) INDSK, INCNO, INVER, OUTDSK, OUTCNO,
* OUTVER
END IF
CALL MSGWRT (3)
END IF
C-----------------------------------------------------------------------
1060 FORMAT ('Reformatted IM file from vol/cno/vers ', I2, I5, I4,
* ' to ', I2, I5, I4)
1061 FORMAT ('Copied IM file from vol/cno/vers ', I2, I5, I4, ' to ',
* I2, I5, I4)
9060 FORMAT ('IMSEL: ERROR ', I3, ' WRITING TO NEW TABLE')
9061 FORMAT ('IMSEL: ERROR ', I3, ' READING FROM OLD TABLE')
9062 FORMAT ('IMSEL: ERROR ', I3, ' CLOSING NEW TABLE')
9063 FORMAT ('IMSEL: ERROR ', I3, ' OPENING NEW TABLE')
9064 FORMAT ('IMSEL: ERROR ', I3, ' CLOSING OLD TABLE')
9065 FORMAT ('IMSEL: ERROR ', I3, ' OPENING OLD TABLE')
END
|
function fv(VS)
include "common6.h"
COMMON/GALAXY/ GMG,RG(3),VG(3),FG(3),FGD(3),TG,
& OMEGA,DISK,A,B,V02,RL2,GMB,AR,GAM,ZDUM(7)
real*8 :: VS, E_DIM, fv
*
!write(206,*) "VS", VS
!Calculate dimensionless energy for star at v and r.
E_DIM = 0.5*VS**2 -(GMB/AR)*(1.d0/(2.d0-GAM))*
& ( 1.d0 - (RGDENSMAG/(RGDENSMAG+AR))**(2.d0-GAM))
!write(206,*) "E_DIM", E_DIM
E_DIM = -E_DIM*(AR/GMB)
!write(206,*) "E_DIM", E_DIM, AR, GMB, GAM, RGDENSMAG, ONEPI
*
!Calculate f(E) (gamma = 0) (Dehnen 1993)
fv = ((3.d0*GMB/(2.d0*(ONEPI**3)*(GMB*AR)**1.5))*
& ((sqrt(2.0*E_DIM) * (3.0-4.0*E_DIM)/(1.0-2.0*E_DIM))
& - 3.0*asinh(sqrt(2.0*E_DIM/(1.0-2.0*E_DIM)))))
!write(206,*) (sqrt(2.0*E_DIM) * (3.0-4.0*E_DIM)/(1.0-2.0*E_DIM))
! & - 3.0*asinh(sqrt(2.0*E_DIM/(1.0-2.0*E_DIM)))
!write(206,*) "fv",fv
*
fv = fv*4.0*ONEPI*VS**2
!write(206,*) "fv",fv
*
end function
|
SUBROUTINE SET_SPEED(SPEED,*)
C.
C. reqd. routines - NONE
C.
C. Subroutine to set the baud rate of the user's terminal
C.
C. CALL SET_SPEED('Speed',&Line #)
C. where:
C. Speed = Character Variable describing the
C. baud rate of the terminal
C. Line #= Line # to go to on illegal baud rate
C.
C. T. Miles, TRIUMF, 05-Apr-1982
C. Modified by J.Chuma to allow 19.2K Nov.22,1985
C---> Specification Statements
C.
IMPLICIT INTEGER*4 (A-Z)
INTEGER DEV_CHR ( 2 )
CHARACTER BAUD_TABLE(16)*5, SPEED*(*)
EXTERNAL IO$_SENSEMODE,IO$_SETMODE
DATA BAUD_TABLE/ '50', '75', '110', '134', '150',
* '300', '600', '1200', '1800', '2000',
* '2400', '3600', '4800', '7200', '9600',
* '19200' /
C.
C---> Procedure begins...
C.
C-- Find the Baud Rate Index
DO 100 BAUD=1,16
100 IF (INDEX(SPEED//' ',BAUD_TABLE(BAUD)) .EQ. 1) GOTO 200
RETURN 1 ! Illegal Baud Rate
C.
C-- Assign the Terminal Device
200 CALL SYS$ASSIGN('TT',CHAN,%VAL(3),)
C.
C-- Set the Baud Rate
CALL SYS$QIO(,%VAL(CHAN),IO$_SENSEMODE,,,,DEV_CHR,,,,,)
CALL SYS$QIO(,%VAL(CHAN),IO$_SETMODE,,,,DEV_CHR,,%VAL(BAUD),,,)
C.
C-- Release the Terminal Device
CALL SYS$DASSGN(%VAL(CHAN))
RETURN
END
|
C $Header: /u/gcmpack/MITgcm/model/src/load_ref_files.F,v 1.2 2010/12/22 00:05:31 jmc Exp $
C $Name: $
c #include "PACKAGES_CONFIG.h"
#include "CPP_OPTIONS.h"
CBOP
C !ROUTINE: LOAD_REF_FILES
C !INTERFACE:
SUBROUTINE LOAD_REF_FILES( myThid )
C !DESCRIPTION: \bv
C *==========================================================*
C | SUBROUTINE LOAD_REF_FILES
C | o Read reference vertical profile from files
C | (Pot.Temp., Salinity/Specif.Humid., density ... )
C *==========================================================*
C \ev
C !USES:
IMPLICIT NONE
C === Global variables ===
#include "SIZE.h"
#include "EEPARAMS.h"
#include "PARAMS.h"
c #include "GRID.h"
C !INPUT/OUTPUT PARAMETERS:
C == Routine arguments ==
C myThid :: my Thread Id number
INTEGER myThid
C !FUNCTIONS:
INTEGER ILNBLNK
EXTERNAL ILNBLNK
C !LOCAL VARIABLES:
C == Local variables ==
C k :: loop index
C msgBuf :: Informational/error message buffer
_RL tracerDefault
INTEGER k, kLen
CHARACTER*(MAX_LEN_MBUF) msgBuf
CEOP
_BEGIN_MASTER( myThid )
C-- Set reference Potential Temperature
IF ( tRefFile .EQ. ' ' ) THEN
C- set default vertical profile for temperature: tRef
tracerDefault = 20.
IF ( fluidIsAir ) tracerDefault = 300.
DO k=1,Nr
IF (tRef(k).EQ.UNSET_RL) tRef(k) = tracerDefault
tracerDefault = tRef(k)
ENDDO
ELSE
C- check for multiple definitions:
DO k=1,Nr
IF (tRef(k).NE.UNSET_RL) THEN
WRITE(msgBuf,'(2A,I4,A)') 'S/R LOAD_REF_FILES:',
& ' Cannot set both tRef(k=', k, ') and tRefFile'
CALL PRINT_ERROR( msgBuf, myThid )
STOP 'ABNORMAL END: S/R INI_PARMS'
ENDIF
ENDDO
ENDIF
C- read from file:
IF ( tRefFile .NE. ' ' ) THEN
kLen = ILNBLNK(tRefFile)
CALL READ_GLVEC_RL( tRefFile, ' ', tRef, Nr, 1, myThid )
WRITE(msgBuf,'(3A)') 'S/R LOAD_REF_FILES:',
& ' tRef loaded from file: ', tRefFile(1:kLen)
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT , myThid )
ENDIF
C-- Set reference Salinity/Specific Humidity
IF ( sRefFile .EQ. ' ' ) THEN
C- set default vertical profile for salinity/water-vapour: sRef
tracerDefault = 30.
IF ( fluidIsAir ) tracerDefault = 0.
DO k=1,Nr
IF (sRef(k).EQ.UNSET_RL) sRef(k) = tracerDefault
tracerDefault = sRef(k)
ENDDO
ELSE
C- check for multiple definitions:
DO k=1,Nr
IF (sRef(k).NE.UNSET_RL) THEN
WRITE(msgBuf,'(2A,I4,A)') 'S/R LOAD_REF_FILES:',
& ' Cannot set both sRef(k=', k, ') and sRefFile'
CALL PRINT_ERROR( msgBuf, myThid )
STOP 'ABNORMAL END: S/R INI_PARMS'
ENDIF
ENDDO
ENDIF
C- read from file:
IF ( sRefFile .NE. ' ' ) THEN
kLen = ILNBLNK(sRefFile)
CALL READ_GLVEC_RL( sRefFile, ' ', sRef, Nr, 1, myThid )
WRITE(msgBuf,'(3A)') 'S/R LOAD_REF_FILES:',
& ' sRef loaded from file: ', sRefFile(1:kLen)
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT , myThid )
ENDIF
C-- Set reference Density
IF ( rhoRefFile .NE. ' ' ) THEN
kLen = ILNBLNK(rhoRefFile)
C- read from file:
CALL READ_GLVEC_RL( rhoRefFile, ' ', rho1Ref, Nr, 1, myThid )
WRITE(msgBuf,'(3A)') 'S/R LOAD_REF_FILES:',
& ' rho1Ref loaded from file: ', rhoRefFile(1:kLen)
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT , myThid)
ENDIF
_END_MASTER(myThid)
C-- Everyone else must wait for the parameters to be loaded
_BARRIER
RETURN
END
|
C$Procedure ZZEKJOIN ( Perform join on two join row sets )
SUBROUTINE ZZEKJOIN ( JBASE1, JBASE2, NJCNST, ACTIVE,
. CPIDX1, CLIDX1, ELTS1, OPS,
. CPIDX2, CLIDX2, ELTS2, STHAN,
. STSDSC, STDTPT, DTPOOL, DTDSCS,
. JBASE3, NROWS )
C$ Abstract
C
C Perform join of two EK join row sets, subject to a specified set
C of EK join constraints, yielding an EK join row set.
C
C$ Disclaimer
C
C THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
C CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
C GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
C ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
C PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
C TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
C WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
C PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
C SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
C SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
C
C IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
C BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
C LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
C INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
C REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
C REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
C
C RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
C THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
C CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
C ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
C
C$ Required_Reading
C
C EK
C
C$ Keywords
C
C EK
C PRIVATE
C
C$ Declarations
INCLUDE 'ekcoldsc.inc'
INCLUDE 'ekjrs.inc'
INCLUDE 'ekqlimit.inc'
INCLUDE 'eksegdsc.inc'
INTEGER LBPOOL
PARAMETER ( LBPOOL = -5 )
INTEGER JBASE1
INTEGER JBASE2
INTEGER NJCNST
LOGICAL ACTIVE ( * )
INTEGER CPIDX1 ( * )
INTEGER CLIDX1 ( * )
INTEGER ELTS1 ( * )
INTEGER OPS ( * )
INTEGER CPIDX2 ( * )
INTEGER CLIDX2 ( * )
INTEGER ELTS2 ( * )
INTEGER STHAN ( * )
INTEGER STSDSC ( SDSCSZ, * )
INTEGER STDTPT ( * )
INTEGER DTPOOL ( 2, LBPOOL : * )
INTEGER DTDSCS ( CDSCSZ, * )
INTEGER JBASE3
INTEGER NROWS
C$ Brief_I/O
C
C Variable I/O Description
C -------- --- --------------------------------------------------
C JBASE1 I Scratch area base address of first join row set.
C JBASE2 I Scratch area base address of second join row set.
C NJCNST I Number of join constraints.
C ACTIVE I Array of flags indicating applicable constraints.
C CPIDX1 I Cross product indices for LHS's of constraints.
C CLIDX1 I Column indices for LHS's of constraints.
C ELTS1 I Column entry elt. indices for LHS'of constraints.
C OPS I Operator codes for constraints.
C CPIDX2 I Cross product indices for RHS's of constraints.
C CLIDX2 I Column indices for RHS's of constraints.
C ELTS2 I Column entry elt. indices for RHS'of constraints.
C STHAN I Array of EK handles corresponding to segments.
C STSDSC I Array of segment descriptors.
C STDTPT I Array of set table column descriptor pointers.
C DTPOOL I Linked list pool for column descriptors.
C DTDSCS I Array of column descriptors.
C JBASE3 O Scratch area base address of output join row set.
C NROWS O Number of rows in output join row set.
C CDSCSZ P Size of column descriptor.
C
C$ Detailed_Input
C
C JBASE1 is the EK scratch area base address of the first
C input join row set. This address is one less than
C the first address occupied by the join row set.
C See the $Particulars section for a description of
C join row sets.
C
C JBASE2 is the EK scratch area base address of the second
C input join row set. This address is one less than
C the first address occupied by the join row set.
C
C NJCNST is the number of join constraints that must be
C satisfied by the output join row set. Each of the
C input arrays CPIDX1, CLIDX1, OPS, CPIDX2, and
C CLIDX2 contains NJCNST elements.
C
C ACTIVE is an array of logical flags indicating which
C constraints are currently applicable. The Nth
C element of ACTIVE indicates whether or not to apply
C the Nth constraint: if ACTIVE(N) is .TRUE., the
C constraint is applicable, otherwise it isn't.
C
C The elements of the other input arguments that
C define constraints are defined when the
C corresponding element of ACTIVE is .TRUE. For
C example, when the second constraint is not active,
C the second column descriptor in DTDSCS may not be
C defined.
C
C CPIDX1,
C CLIDX1 are, respectively, a set of cross product indices
C and column indices that define the columns on the
C left-hand sides of the input constraints. If the
C first input join row set contains rows from NT1
C tables and the second input join row set contains
C rows from NT2 tables, then there are (NT1+NT2)
C components in the cross product of the tables
C specified by the input join row sets. We'll index
C these from 1 to (NT1+NT2), with table 1 being the
C first table of the first input join row set, table
C 2 being the second table of the first input join
C row set, table (NT1+1) being the first table of the
C second input join row set, and so on. Each element
C of the argument CPIDX1 designates a table by this
C counting scheme. The corresponding element of the
C argument CLIDX1 is the index of a column in the
C specified table. The index is the ordinal position
C of the column's attributes in the column attribute
C list for the table containing the column.
C
C ELTS1 is an array of column entry element indices. These
C indices specify the elements of the LHS column
C entries to be used in testing the join constraints.
C For scalar columns, the corresponding values of
C ELTS1 are ignored.
C
C OPS is an array of relational operator codes. The
C Ith code applies to the Ith join constraint.
C
C CPIDX2,
C CLIDX2 are, respectively, a set of cross product indices
C and column indices that define the columns on the
C right-hand sides of the input constraints. The
C meanings of these arrays are analogous to those
C of CPIDX1 and CLIDX1.
C
C ELTS2 is an array of column entry element indices. These
C indices specify the elements of the LHS column
C entries to be used in testing the join constraints.
C For scalar columns, the corresponding values of
C ELTS2 are ignored.
C
C STHAN is an array of EK file handles. The Ith element
C of STHAN is the handle of the EK containing the
C Ith loaded segment.
C
C STSDSC is an array of segment descriptors for all of the
C loaded segments.
C
C STDTPT is an array of descriptor table pointers all of
C the loaded segments. For the Ith loaded segment,
C
C STDTPT(I)
C
C contains the node number of the descriptor entry
C of the first column in the Ith segment, where the
C order of columns is determined by the order in
C which the columns appear in the parent table's
C column attribute list.
C
C DTPOOL,
C DTDSCS are, respectively, the linked list pool for
C the column descriptor array and the column
C descriptor array itself. The latter contains
C a descriptor for each loaded column.
C
C$ Detailed_Output
C
C JBASE3 is the EK scratch area base address of the output
C join row set. This join row set represents that
C subset of the Cartesian product of the input
C join row sets which satisfies all of the input
C join constraints.
C
C NROWS is the number of `rows' in the output join row set.
C Each such row is actually a vector of rows, one
C belonging to each table in the Cartesian product
C of tables specified by the join operation.
C
C$ Parameters
C
C See the include files.
C
C$ Exceptions
C
C 1) If the number of constaints NCNSTR is out of range, the
C error SPICE(INVALIDCOUNT) is signalled.
C
C 2) If the table count in either input join row set is out of
C range, the error SPICE(INVALIDCOUNT) is signalled.
C
C 3) If the sum of the table counts of the input join row sets is
C too large, the error SPICE(INVALIDCOUNT) is signalled.
C
C 4) If either of cross product table indices for the input
C constraints is out of range, the error SPICE(INVALIDINDEX) is
C signalled.
C
C$ Files
C
C 1) This routine uses the EK scratch area, which employs a scratch
C DAS file.
C
C$ Particulars
C
C The purpose of this routine is to compute the set of rows
C resulting from joining two `join row sets'. A join row set
C is a structure in the EK scratch area that represents the
C result of a table join, subject to constraints. A join of
C n tables, subject to constraints, may be computed by joining
C the join of the first n-1 tables with the nth table; such a
C procedure is the typical application evisioned for this routine.
C
C Since all EK rows belong to segments, the set of rows formed by
C taking the Cartesian product of two tables is actually the union
C of the sets of rows belonging to the Cartesian products of the
C possible pairs of segments, where the segments are taken from
C the two tables being crossed. Therefore, each join row set is
C characterized by a list of n-tuples of segments, and by a list of
C sets of n-tuples of row numbers, one row number set per segment
C n-tuple. The segments are identified by a vector of segment
C list indices, which is called a `segment vector'. The n-tuples
C of rows are called `row vectors'. Each segment vector has a
C pointer and count that allow addressing the corresponding row
C vectors.
C
C Each join row set consists of:
C
C - a base address in the scratch area
C - a table count
C - a segment vector count
C - a set of segment vectors
C - a set of segment vector row vector base addresses
C (these are relative to the base of the join row set)
C - a set of segment vector row vector counts
C - a set of row vectors, augmented by offsets of their
C parent segment vectors (these offsets are at the
C end of each row vector)
C
C
C The layout of a join row set in the EK scratch area is shown
C in the include file for the join row set parameters.
C
C$ Examples
C
C See EKSRCH.
C
C$ Restrictions
C
C 1) Relies on the EK scratch area.
C
C$ Literature_References
C
C None.
C
C$ Author_and_Institution
C
C N.J. Bachman (JPL)
C
C$ Version
C
C- SPICELIB Version 1.0.1, 20-JUL-1998 (NJB)
C
C Deleted comment about squeezing out segment vectors without
C corresponding row vectors; also deleted comment containing
C a call to ZZEKJSQZ.
C
C- Beta Version 1.0.0, 10-OCT-1995 (NJB)
C
C-&
C
C Local variables
C
INTEGER I
INTEGER OFFSET
INTEGER NR1
INTEGER NR2
INTEGER NR3
INTEGER NRESV
INTEGER NSV1
INTEGER NSV2
INTEGER NSV3
INTEGER NT1
INTEGER NT2
INTEGER NT3
INTEGER RB1
INTEGER RB2
INTEGER RB3
INTEGER ROWVEC ( MXJOIN + 1 )
INTEGER S1
INTEGER S2
INTEGER S3
INTEGER SEGVEC ( MXJOIN )
INTEGER SGVBAS
INTEGER TOP
LOGICAL FOUND
C
C For speed, we use discovery check-in. We don't check
C RETURN at all.
C
C
C Validate constraint count.
C
IF ( ( NJCNST .LT. 0 ) .OR. ( NJCNST .GT. MXJCON ) ) THEN
CALL CHKIN ( 'ZZEKJOIN' )
CALL SETMSG ( 'Number of join constraints was #; valid ' //
. 'range is 0:#' )
CALL ERRINT ( '#', NJCNST )
CALL ERRINT ( '#', MXJCON )
CALL SIGERR ( 'SPICE(INVALIDCOUNT)' )
CALL CHKOUT ( 'ZZEKJOIN' )
RETURN
END IF
C
C Get the table count and segment vector count for each input join
C row set.
C
CALL ZZEKSRD ( JBASE1+JTCIDX, JBASE1+JTCIDX, NT1 )
CALL ZZEKSRD ( JBASE1+JSCIDX, JBASE1+JSCIDX, NSV1 )
CALL ZZEKSRD ( JBASE2+JTCIDX, JBASE2+JTCIDX, NT2 )
CALL ZZEKSRD ( JBASE2+JSCIDX, JBASE2+JSCIDX, NSV2 )
C
C Set the table count and segment vector count for the output join
C row set.
C
NT3 = NT1 + NT2
NSV3 = NSV1 * NSV2
IF ( ( NT1 .LT. 1 ) .OR. ( NT2 .GT. MXJOIN-1 ) ) THEN
CALL CHKIN ( 'ZZEKJOIN' )
CALL SETMSG ( 'Number tables in first join row set was #; ' //
. 'valid range is 1:#' )
CALL ERRINT ( '#', NT1 )
CALL ERRINT ( '#', MXJOIN-1 )
CALL SIGERR ( 'SPICE(INVALIDCOUNT)' )
CALL CHKOUT ( 'ZZEKJOIN' )
RETURN
ELSE IF ( ( NT2 .LT. 1 ) .OR. ( NT2 .GT. MXJOIN-1 ) ) THEN
CALL CHKIN ( 'ZZEKJOIN' )
CALL SETMSG ( 'Number tables in second join row set was #; ' //
. 'valid range is 1:#' )
CALL ERRINT ( '#', NT2 )
CALL ERRINT ( '#', MXJOIN-1 )
CALL SIGERR ( 'SPICE(INVALIDCOUNT)' )
CALL CHKOUT ( 'ZZEKJOIN' )
RETURN
ELSE IF ( NT3 .GT. MXJOIN ) THEN
CALL CHKIN ( 'ZZEKJOIN' )
CALL SETMSG ( 'Number of crossed tables was #; valid ' //
. 'range is 0:#' )
CALL ERRINT ( '#', NT3 )
CALL ERRINT ( '#', MXJOIN )
CALL SIGERR ( 'SPICE(INVALIDCOUNT)' )
CALL CHKOUT ( 'ZZEKJOIN' )
RETURN
END IF
C
C Validate cross product indices. The column indices don't lend
C themselves to such a convenient check; we'll check those as we
C use them.
C
DO I = 1, NJCNST
IF ( ACTIVE(I) ) THEN
IF ( ( CPIDX1(I) .LT. 1 )
. .OR. ( CPIDX1(I) .GT. NT3 ) ) THEN
CALL CHKIN ( 'ZZEKJOIN' )
CALL SETMSG ( 'Cross product table index for left ' //
. 'hand side of constraint # was #; ' //
. 'valid range is 1:#' )
CALL ERRINT ( '#', I )
CALL ERRINT ( '#', CPIDX1(I) )
CALL ERRINT ( '#', NT3 )
CALL SIGERR ( 'SPICE(INVALIDINDEX)' )
CALL CHKOUT ( 'ZZEKJOIN' )
RETURN
ELSE IF ( ( CPIDX2(I) .LT. 1 )
. .OR. ( CPIDX2(I) .GT. NT3 ) ) THEN
CALL CHKIN ( 'ZZEKJOIN' )
CALL SETMSG ( 'Cross product table index for right ' //
. 'hand side of constraint # was #; ' //
. 'valid range is 1:#' )
CALL ERRINT ( '#', I )
CALL ERRINT ( '#', CPIDX2(I) )
CALL ERRINT ( '#', NT3 )
CALL SIGERR ( 'SPICE(INVALIDINDEX)' )
CALL CHKOUT ( 'ZZEKJOIN' )
RETURN
END IF
END IF
END DO
C
C Form the joint row set control area for output join row set.
C
C The current stack top is the base address of the output join row
C set.
C
CALL ZZEKSTOP ( JBASE3 )
C
C Save room for the size and row vector count
C
DO I = 1, 2
CALL ZZEKSPSH ( 1, 0 )
END DO
C
C The table count and segment vector count come next.
C
CALL ZZEKSPSH ( 1, NT3 )
CALL ZZEKSPSH ( 1, NSV3 )
C
C Just reserve room for the segment vectors and the segment vector
C row set base addresses and counts.
C
NRESV = NSV3 * ( NT3 + 2 )
DO I = 1, NRESV
CALL ZZEKSPSH ( 1, 0 )
END DO
C
C Initialize the output segment vector count and the total row
C count.
C
S3 = 0
NROWS = 0
C
C For every segment vector in the first join row set,
C
DO S1 = 1, NSV1
C
C Fill in the first NT1 elements of our composite segment vector
C with the current segment vector from the first join row set.
C
OFFSET = JSVBAS + (S1 - 1) * NT1
CALL ZZEKSRD ( JBASE1+OFFSET+1, JBASE1+OFFSET+NT1, SEGVEC )
C
C Get the row set base address and count for this segment vector.
C
OFFSET = JSVBAS + NSV1*NT1 + 2*( S1 - 1 ) + 1
CALL ZZEKSRD ( JBASE1+OFFSET, JBASE1+OFFSET, RB1 )
CALL ZZEKSRD ( JBASE1+OFFSET+1, JBASE1+OFFSET+1, NR1 )
C
C For every segment vector in the second join row set,
C
DO S2 = 1, NSV2
C
C Fill in the last NT2 elements of our composite segment
C vector with the current segment vector from the second join
C row set.
C
OFFSET = JSVBAS + (S2 - 1) * NT2
CALL ZZEKSRD ( JBASE2+OFFSET+1,
. JBASE2+OFFSET+NT2, SEGVEC(NT1+1) )
C
C Write this segment vector to the output join row set.
C
S3 = S3 + 1
SGVBAS = JSVBAS + ( S3 - 1 ) * NT3
CALL ZZEKSUPD ( JBASE3+SGVBAS+1, JBASE3+SGVBAS+NT3, SEGVEC )
C
C Get the row set base address and count for this segment
C vector.
C
OFFSET = JSVBAS + NSV2*NT2 + 2*( S2 - 1 ) + 1
CALL ZZEKSRD ( JBASE2+OFFSET, JBASE2+OFFSET, RB2 )
CALL ZZEKSRD ( JBASE2+OFFSET+1, JBASE2+OFFSET+1, NR2 )
C
C It's time to decide which row vectors corresponding to
C our two segment vectors satisfy the join constraints.
C We pass off the job of determining which row vectors to
C consider to the subroutine pair ZZEKJPRP (join preparation)
C and ZZEKJNXT (get next joined row vector).
C
C We defer establishing the base address of the output
C row vector set until the join reduction is done, since
C the join operation will use the scratch area.
C
CALL ZZEKJPRP ( SEGVEC,
. JBASE1, NT1, RB1, NR1,
. JBASE2, NT2, RB2, NR2,
. NJCNST, ACTIVE,
. CPIDX1, CLIDX1, ELTS1,
. OPS,
. CPIDX2, CLIDX2, ELTS2,
. STHAN, STSDSC, STDTPT, DTPOOL, DTDSCS )
C
C Initialize the row count for the current output segment
C vector. Also set the segment vector row set base address.
C
NR3 = 0
CALL ZZEKSTOP ( TOP )
RB3 = TOP - JBASE3
OFFSET = JSVBAS + NSV3*NT3 + ( S3 - 1 ) * 2 + 1
CALL ZZEKSUPD ( JBASE3+OFFSET, JBASE3+OFFSET, RB3 )
C
C Fetch the row vectors that satisfy the join constraints.
C
NR3 = 0
CALL ZZEKJNXT ( FOUND, ROWVEC )
DO WHILE ( FOUND )
C
C Append the base offset of the parent segment vector
C to the row vector. The base offset is one less than
C the base-relative address of the segment vector.
C
NR3 = NR3 + 1
ROWVEC ( NT3 + 1 ) = SGVBAS
C
C Add this vector to the output join row set. Get the
C next row vector.
C
CALL ZZEKSPSH ( NT3 + 1, ROWVEC )
CALL ZZEKJNXT ( FOUND, ROWVEC )
END DO
C
C At this point, we've tested every row corresponding to the
C current segment vector. Update the row count for this
C segment vector.
C
OFFSET = JSVBAS + NSV3*NT3 + ( S3 - 1 ) * 2 + 2
CALL ZZEKSUPD ( JBASE3+OFFSET, JBASE3+OFFSET, NR3 )
C
C Keep the overall row total up to date.
C
NROWS = NROWS + NR3
END DO
END DO
C
C Fill in the row count and size values in the output join row
C set.
C
CALL ZZEKSTOP ( TOP )
CALL ZZEKSUPD ( JBASE3+JSZIDX, JBASE3+JSZIDX, TOP-JBASE3 )
CALL ZZEKSUPD ( JBASE3+JRCIDX, JBASE3+JRCIDX, NROWS )
C
C We've constructed the output join row set resulting from
C joining the input row sets.
C
RETURN
END
|
PROGRAM CALC_SLENGTH
USE ANGSYM
REAL*8 :: RADA, SLENGTH
INTEGER :: MODEL, NDVR, LMAX, MAN, LAN, KSYM, NANG, NSPS
INTEGER, ALLOCATABLE :: L(:), M(:)
COMPLEX*16, ALLOCATABLE :: CK(:)
CHARACTER(30) :: STR, FILENAME, SYMNAME
IF (IARGC() .LT. 7) STOP 'AT LEAST 7 PARAMETERS REQUIRED'
CALL GETARG(1, STR)
READ(STR,*) MODEL
CALL GETARG(2, STR)
READ(STR,*) RADA
CALL GETARG(3, STR)
READ(STR,*) NDVR
CALL GETARG(4, STR)
READ(STR,*) LMAX
CALL GETARG(5, STR)
READ(STR,*) LAN
CALL GETARG(6, STR)
READ(STR,*) MAM
CALL GETARG(7, STR)
READ(STR,*) KSYM
CALL ANGBAS(KSYM,L,M,LMAX,NANG,LAN,MAN)
NSPS = 0
DO i= 1, NANG
NSPS = NSPS + 2 * NDVR + L(i)
ENDDO
DEALLOCATE(L, M)
ALLOCATE(CK(NSPS))
FILENAME=SYMNAME('L', MODEL,KSYM,NDVR,LMAX,INT(RADA),MAN)
OPEN(UNIT = 1, FILE=FILENAME, FORM = 'unformatted',
& ACCESS = 'direct', RECL = NSPS * 16)
READ(1, REC = 1) CK
CLOSE(1)
PRINT *, SLENGTH(RADA,NSPS,NANG,CK)
END |
c
c*********************
c
subroutine modobs(xr,xo,wtfunc,tfunc,errscale,ru,rt)
complex xr(*),xo,tfunc(3),xp
real ru,rt
external wtfunc
xp=tfunc(1)*xr(1)+tfunc(2)*xr(2)
pr=real(xp)
pi=aimag(xp)
zr=real(xo)
zi=aimag(xo)
w=abs(zr-pr)/errscale
rt = w*w
call wtfunc(w,psiprime)
ru=psiprime
zr=w*zr+(1.-w)*pr
w=abs(zi-pi)/errscale
rt = rt + w*w
call wt(w,psiprime)
ru=ru+psiprime
zi=w*zi+(1.-w)*pi
xo=cmplx(zr,zi)
return
end
|
*
* $Id: smxvec.F,v 1.1 2003/03/05 17:44:48 dpp Exp $
*
* $Log: smxvec.F,v $
* Revision 1.1 2003/03/05 17:44:48 dpp
* -> NEW ROUTINE, moved from "fitter/."
* -> changed all variable names in cdscrtcd to have common root
*
* Revision 1.2 2001/11/19 23:44:15 dpp
* -> delete unused include file
*
* Revision 1.1.1.1 1998/02/06 19:11:43 dpp
* DOIT first release.
*
* Revision 1.1.1.1 1997/04/30 12:31:28 clib
* Developmental version of DUET.
*
* Revision 1.1.1.1 1994/10/08 01:00:49 zfiles
* first version of doit in CVS
*
*
#include "sys/CLEO_machine.h"
#include "pilot.h"
*CMZ : 5.54/07 10/10/91 14.53.06 by Jon Urheim
* add UNIX flag to +SELF statement.
*CMZ : 5.54/04 21/05/91 14.40.54 by Steve Schaffner
*CMZ : 5.53/03 17/04/90 12.14.02 by D. Riley
*CMZ : 5.51/00 09/08/89 13.17.07 by Steve Schaffner
*CMZ : 5.50/00 25/02/88 19.50.39 by R. Namjoshi
*-- Author :
SUBROUTINE SMXVEC( A, B, C, N )
C.......................................................................
C.
C. SMXVEC - Multiply column vector by symmetric matrix
C.
C. COMMON : ?
C. CALLS : None
C. CALLED : Various places
C. AUTHOR : M. Ogg. Converted to Fortran-77 by R. Namjoshi
C.
C. VERSION : 1.00
C. CREATED : ?
C. LAST MOD : 01-Apr-87
C.
C. Modification Log.
C.
C.......................................................................
#if defined(CLEO_TYPCHK)
IMPLICIT NONE
#endif
SAVE
C
C=======================================================================
C
C MULTIPLY A COLUMN VECTOR BY A SYMMETRIC MATRIX:
C C(I) = A(IJ)*B(J)
C
C MATRIX A IS STORED IN PACKED LOWER TRIANGULAR FORM:
C
C A = A(1)
C A(2) A(3)
C A(4) A(5) A(6)
C ............A(N(N+1)/2)
C
C N IS THE ORDER OF THE MATRIX: ==> A HAS N(N+1)/2 ELEMENTS
C DOUBLE PRECISION IS USED INTERNALLY ON THE VAX & IBM
C
C=======================================================================
C
REAL A(*),B(*),C(*)
INTEGER IROW,N,I,J,JROW
C
#if defined(CLEO_PDP10)
REAL CC
#endif
#if defined(CLEO_VAX)||defined(CLEO_IBM)||defined(CLEO_DECS)||defined(CLEO_UNIX)
DOUBLE PRECISION CC
#endif
* ----------Executable code starts here---------------------
IF( N.LE.0 ) RETURN
IROW = 0
DO 10 I = 1, N
CC = 0
IROW = IROW + I - 1
DO 20 J = 1, I
CC = CC + A(IROW+J)*B(J)
20 CONTINUE
IF( I.LT.N ) THEN
JROW = IROW + I
DO 30 J = I+1, N
JROW = JROW + J - 1
CC = CC + A(JROW)*B(J)
30 CONTINUE
ENDIF
C(I) = CC
10 CONTINUE
RETURN
END
|
SUBROUTINE F04FEF(N,T,X,WANTP,P,WANTV,V,VLAST,WORK,IFAIL)
C MARK 15 RELEASE. NAG COPYRIGHT 1991.
C -- Written on 9-February-1990.
C This version dated 29-December-1990.
C Sven Hammarling, Nag Ltd.
C
C .. Parameters ..
DOUBLE PRECISION ONE, ZERO
PARAMETER (ONE=1.0D+0,ZERO=0.0D+0)
CHARACTER*6 SRNAME
PARAMETER (SRNAME='F04FEF')
C .. Scalar Arguments ..
DOUBLE PRECISION VLAST
INTEGER IFAIL, N
LOGICAL WANTP, WANTV
C .. Array Arguments ..
DOUBLE PRECISION P(*), T(0:N), V(*), WORK(*), X(*)
C .. Local Scalars ..
DOUBLE PRECISION ALPHA, BETA
INTEGER I, IERR
C .. Local Arrays ..
CHARACTER*53 REC(2)
C .. External Functions ..
DOUBLE PRECISION DDOT
INTEGER P01ABF
EXTERNAL DDOT, P01ABF
C .. External Subroutines ..
EXTERNAL P01ABX, P01ABY, DAXPY, DCOPY
C .. Intrinsic Functions ..
INTRINSIC ABS
C .. Executable Statements ..
C
C
C Check the input parameters.
C
IERR = 0
IF (N.LT.0) CALL P01ABY(N,'N',IFAIL,IERR,SRNAME)
IF (T(0).LE.ZERO) CALL P01ABX(T(0),'T(0)',IFAIL,IERR,SRNAME)
IF (IERR.GT.0) THEN
WRITE (REC,FMT=99999) IERR
IFAIL = P01ABF(IFAIL,-1,SRNAME,1,REC)
RETURN
END IF
C
C Start the recursion.
C
BETA = T(0)
DO 20 I = 1, N
C
C Make a copy of the previous solution (in reverse order) to
C simplify the code and to allow the call to DAXPY.
C
CALL DCOPY(I-1,X,-1,WORK,1)
ALPHA = -(T(I)+DDOT(I-1,T(1),1,WORK,1))/BETA
CALL DAXPY(I-1,ALPHA,WORK,1,X,1)
X(I) = ALPHA
BETA = (ONE-ALPHA)*(ONE+ALPHA)*BETA
IF (WANTP) P(I) = ALPHA
IF (WANTV) V(I) = BETA/T(0)
IF (ABS(ALPHA).GE.ONE) THEN
VLAST = BETA/T(0)
WRITE (REC,FMT=99998) I + 1, ALPHA
IFAIL = P01ABF(IFAIL,I,SRNAME,2,REC)
RETURN
END IF
20 CONTINUE
VLAST = BETA/T(0)
C
IFAIL = P01ABF(IFAIL,0,SRNAME,0,REC)
RETURN
C
C
C End of F04FEF.
C
99999 FORMAT (' The input parameters contained ',I2,' error(s)')
99998 FORMAT (' Principal minor ',I8,' is not positive-definite',
* /' Value of the reflection coefficient is ',1P,D10.2)
END
|
C LAST UPDATE 16/03/89
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
SUBROUTINE CROSS (X,XX,Y,YY,YYY,XXX)
IMPLICIT NONE
C
C Purpose: Interpolates cross point between curve and shadow.
C
REAL X,XX,Y,YY,YYY,XXX
C
C X : Abscissa value 1
C XX : Abscissa value 2
C Y : Ordinate value 1
C YY : Ordinate value 2
C YYY : Interpolated Ordinate
C XXX : Interpolated abscissa
C
C Calls 0:
C
C-----------------------------------------------------------------------
YYY=Y-YY+XX-X
XXX=Y*(XX-X)+X*(Y-YY)
IF (ABS(YYY).GE.1.E-6) THEN
YYY=XXX/YYY
XXX=XX-X
IF (ABS(XXX).GE.1.E-6) THEN
XXX=(YYY-X)/XXX
ELSE
XXX=Y-YY
IF (ABS(XXX).GE.1.E-6) THEN
XXX=(Y-YYY)/XXX
ENDIF
ENDIF
ENDIF
RETURN
END
|
PROGRAM C03EX03
INTEGER*2 A, B, R
WRITE(*, 10)
10 FORMAT("Entre os valores para as variaveis <A> e <B>.")
READ(*, 20) A
READ(*, 20) B
20 FORMAT(2I6)
R = A + B
IF (R .GE. 10) THEN
WRITE(*, 30) R + 5
30 FORMAT("Resultado = ", I6)
ELSE
WRITE(*, 40) R - 7
40 FORMAT("Resultado = ", I6)
ENDIF
END
|
FUNCTION factrl(n)
INTEGER n
REAL factrl
CU USES gammln
INTEGER j,ntop
REAL a(33),gammln
SAVE ntop,a
DATA ntop,a(1)/0,1./
if (n.lt.0) then
pause 'negative factorial in factrl'
else if (n.le.ntop) then
factrl=a(n+1)
else if (n.le.32) then
do 11 j=ntop+1,n
a(j+1)=j*a(j)
11 continue
ntop=n
factrl=a(n+1)
else
factrl=exp(gammln(n+1.))
endif
return
END
|
subroutine check_switches2 (ierr)
implicit none
integer*4 ierr, iwest, ieast, isouth, inorth, iAk
integer*4 LLm,Lm,MMm,Mm,N, LLm0,MMm0
parameter (LLm0=1519, MMm0=1399, N=32)
integer*4 Lmmpi,Mmmpi,iminmpi,imaxmpi,jminmpi,jmaxmpi
common /comm_setup_mpi/ Lmmpi,Mmmpi,
& iminmpi,imaxmpi,jminmpi,jmaxmpi
parameter (LLm=LLm0, MMm=MMm0)
integer*4 NSUB_X, NSUB_E, NPP
integer*4 NP_XI, NP_ETA, NNODES
parameter (NP_XI=1, NP_ETA=8, NNODES=NP_XI*NP_ETA)
parameter (NPP=1)
parameter (NSUB_X=1, NSUB_E=1)
integer*4 stdout, Np, padd_X,padd_E
parameter (stdout=6, Np=N+1)
parameter (Lm=(LLm+NP_XI-1)/NP_XI, Mm=(MMm+NP_ETA-1)/NP_ETA)
parameter (padd_X=(Lm+2)/2-(Lm+1)/2)
parameter (padd_E=(Mm+2)/2-(Mm+1)/2)
integer*4 NSA, N2d,N3d, size_XI,size_ETA
integer*4 se,sse, sz,ssz
parameter (NSA=28)
parameter (size_XI=7+(Lm+NSUB_X-1)/NSUB_X)
parameter (size_ETA=7+(Mm+NSUB_E-1)/NSUB_E)
parameter (sse=size_ETA/Np, ssz=Np/size_ETA)
parameter (se=sse/(sse+ssz), sz=1-se)
parameter (N2d=size_XI*(se*size_ETA+sz*Np))
parameter (N3d=size_XI*size_ETA*Np)
integer*4 NWEIGHT
parameter (NWEIGHT=137)
real dt, dtfast, time, time_start, tdays
integer*4 iic, kstp, krhs, knew, next_kstp
logical PREDICTOR_2D_STEP
common /time_indices/ dt,dtfast, time,time_start, tdays,
& iic, kstp, krhs, knew, next_kstp,
& PREDICTOR_2D_STEP
real time_avg, rho0
& , rdrg, rdrg2, Cdb_min, Cdb_max, Zob
& , xl, el, visc2, visc4, gamma2
real x_sponge, v_sponge
real tauT_in, tauT_out, tauM_in, tauM_out
integer*4 numthreads, ntstart, ntimes, ninfo
& , ndtfast,nfast, nrrec, nrst, nwrt
& , ntsavg, navg
logical ldefhis
common /scalars_main/
& time_avg, rho0, rdrg, rdrg2
& , Zob, Cdb_min, Cdb_max
& , xl, el, visc2, visc4, gamma2
& , x_sponge, v_sponge
& , tauT_in, tauT_out, tauM_in, tauM_out
& , numthreads, ntstart, ntimes, ninfo
& , ndtfast,nfast, nrrec, nrst, nwrt
& , ntsavg, navg
& , ldefhis
logical synchro_flag
common /sync_flag/ synchro_flag
integer*4 may_day_flag
integer*4 tile_count, first_time, bc_count
common /communicators_i/
& may_day_flag, tile_count, first_time, bc_count
real hmin, hmax, grdmin, grdmax, Cu_min, Cu_max
common /communicators_r/
& hmin, hmax, grdmin, grdmax, Cu_min, Cu_max
real*8 volume, avgke, avgpe, avgkp, bc_crss
common /communicators_rq/
& volume, avgke, avgpe, avgkp, bc_crss
real*4 CPU_time(0:31,0:NPP)
integer*4 proc(0:31,0:NPP),trd_count
common /timers/CPU_time,proc,trd_count
logical EAST_INTER
logical WEST_INTER
logical NORTH_INTER
logical SOUTH_INTER
integer mynode, ii,jj, p_W,p_E,p_S,p_N, p_SW,p_SE, p_NW,p_NE
common /comm_setup/ mynode,ii,jj,p_W,p_E,p_S,p_N,p_SW,p_SE
common /comm_setup/ p_NW,p_NE, EAST_INTER, WEST_INTER
common /comm_setup/ NORTH_INTER, SOUTH_INTER
real pi, deg2rad, rad2deg
parameter (pi=3.14159265358979323846D0, deg2rad=pi/180.D0,
& rad2deg=180.D0/pi)
real Eradius, g, day2sec,sec2day, jul_off,
& year2day,day2year
parameter (Eradius=6371315.0D0, day2sec=86400.D0,
& sec2day=1.D0/86400.D0, jul_off=2440000.D0,
& year2day=365.25D0, day2year=1.D0/365.25D0)
parameter (g=9.81D0)
real Cp
parameter (Cp=3985.0D0)
real vonKar
parameter (vonKar=0.41D0)
iwest=0
ieast=0
iwest=iwest+1
ieast=ieast+1
if (iwest.gt.1) then
write(stdout,'(1x,A,1x,A)')'ERROR in "cppdefs.h": more tnan',
& 'one boundary condition is chosen on the WESTERN EGGE.'
ierr=ierr+1
endif
if (ieast.gt.1) then
write(stdout,'(1x,A,1x,A)')'ERROR in "cppdefs.h": more tnan',
& 'one boundary condition is chosen on the EASTERN EGGE.'
ierr=ierr+1
endif
isouth=0
inorth=0
isouth=isouth+1
inorth=inorth+1
if (isouth.gt.1) then
write(stdout,'(1x,A,1x,A)')'ERROR in "cppdefs.h": more tnan',
& 'one boundary condition is chosen on the SOUTHERN EGGE.'
ierr=ierr+1
endif
if (inorth.gt.1) then
write(stdout,'(1x,A,1x,A)')'ERROR in "cppdefs.h": more tnan',
& 'one boundary condition is chosen on the NORTHERN EGGE.'
ierr=ierr+1
endif
iAk=0
if (iAk.gt.1) then
write(stdout,'(1x,A,1x,A)') 'ERROR in "cppdefs.h":',
& 'more than one vertical mixing scheme is chosen.'
ierr=ierr+1
endif
if (ndtfast.gt.1) then
write(stdout,'(1x,A,I3,1x,A/8x,A,6x,A)') 'ERROR: NDTFAST =',
& ndtfast, 'is greater than unity for a shallow water',
& 'configuration.','Change it to unity in startup file.'
ierr=ierr+1
endif
return
end
|
SUBROUTINE OVLT1T2(CMO1,CMO2,T12,DSTO,CCSET2)
C
C Purpose: Calculate orbital overlaps between time steps
C
C History: - Creation (10.07.15, LGMP)
C
C ******************************************************************
C
C List of local dimensions:
C
C DSTO: Dimension of Slater type orbital matrix.
C
C List of local variables:
C
C List of local dynamical fields:
C
C SMAT : Overlap matrix
C CMO1 : MO's from present time step
C CMO2 : MO's from next time step
C T12 : Final transformed overlap matrix
C
C ------------------------------------------------------------------
C
IMPLICIT NONE
C
INTEGER DSTO,CCSET2,ALLOCATION,I,J
REAL CMO1(DSTO,DSTO,2),CMO2(DSTO,DSTO,2),T12(DSTO,DSTO,2)
C
REAL,ALLOCATABLE :: SMAT(:,:)
C
C ------------------------------------------------------------------
C
C *** Allocate local fields ***
C
ALLOCATE(SMAT(DSTO,DSTO),STAT=ALLOCATION)
IF (ALLOCATION.GT.0) THEN
CALL ERRMSG('OVLT1T2','ALLOCATION FAILED',1)
END IF
CALL BLDSMAT2(SMAT,DSTO,CCSET2)
T12(:,:,1) = SMAT(:,:)
T12(:,:,2) = SMAT(:,:)
C
C *** Transform index for time t
C
DO I = 1,2
C
C *** Transform index for time t
C
CALL MPMULMAT(CMO1(1,1,I),T12(1,1,I),SMAT,DSTO,DSTO,'TRANSA')
C
C *** Transform index for time t+1
C
CALL MPMULMAT(SMAT,CMO2(1,1,I),T12(1,1,I),DSTO,DSTO,'NORMAL')
ENDDO
C
DEALLOCATE(SMAT,STAT=ALLOCATION)
IF (ALLOCATION.GT.0) THEN
CALL ERRMSG('OVLT12','DEALLOCATION FAILED',1)
END IF
C
C ------------------------------------------------------------------
C
C *** End of SUBROUTINE OVLT12 ***
C
END
|
integer function isizof(data)
#if defined(sun)
implicit undefined (a-z)
#else
implicit integer (a-z)
#endif
character*(*) data
if (data .eq. 'REAL') then
isizof = 2
else if (data .eq. 'REAL_IN_BYTES') then
isizof = 8
else if (data .eq. 'INT') then
isizof = 1
else if (data .eq. 'INT_IN_BYTES') then
isizof = 4
else
write(6,*) 'isizof: illegal type: ', data
call mabort
endif
return
end
|
Subroutine Check_PossibleDisplacement(Qd,Qd1,Qd2,
& Qdp1,Qdp2,
& nA,DeltaLamdai1,DeltaLamdai2,iOut)
Implicit Real(kind=8) (a-h,o-z)
! At the beginning of each Loadstep
Real(kind=8) Qd ,Qd1 ,Qd2 ,Qdp1 ,Qdp2
Dimension Qd(nA),Qd1(nA),Qd2(nA),Qdp1(nA),Qdp2(nA)
DATA zero/0.D0/,one/1.0D0/,two/2.D0/
!
do 20 i = 1,nA
Qdp1(i) = Qd(i) + Qd1(i) + DeltaLamdai1 * Qd2(i)
Qdp2(i) = Qd(i) + Qd1(i) + DeltaLamdai2 * Qd2(i)
20 continue
!
!
! done
!
iPrt = 0
if(iPrt == 1) Then
write(iOut,1010) nA,(Qdp1(j),j = 1,nA)
write(iOut,1020) nA,(Qdp2(j),j = 1,nA)
endif
!
return
!
1010 format("Check_PossibleDisplacement:delUi1p(",I2,")"/
& (5(f16.10,1X)/))
1020 format("Check_PossibleDisplacement:delUi2p(",I2,")"/
& (5(f16.10,1X)/))
end
|
subroutine psphexll(posupo,M,posuloc,nnod,dumpo)
implicit NONE
!-------------------------------------------------------------------
! This subroutine saves (nnod x 8 array)dumpo array into linked list
! The ending and starting of the linked list is stored in psuloc.
!
! elem: elements array
! nelem: Number of elements
! nnod: Number of nodes
!-------------------------------------------------------------------
! Subroutine Variables
INTEGER dumpo(nnod,27),nnod
INTEGER M,posupo(M),posuloc(nnod+1)
! Variables of the subroutine
integer pnt1,pnt2,inod,ielem,flag,icount,N
flag=1
posuloc(1)=1
do inod=1,nnod
do icount=1,27
if(dumpo(inod,icount).ne.0) then
posupo(flag)=dumpo(inod,icount)
flag=flag+1
endif
enddo
posuloc(inod+1)=flag
pnt1=posuloc(inod)
pnt2=posuloc(inod+1)-1
N=posuloc(inod+1)-posuloc(inod)
call intsort(posupo(pnt1:pnt2),N)
enddo
end
|
C $Header: /u/gcmpack/MITgcm/model/src/cg2d_sr.F,v 1.4 2011/06/08 01:46:34 jmc Exp $
C $Name: $
#include "CPP_OPTIONS.h"
#ifdef TARGET_NEC_SX
C set a sensible default for the outer loop unrolling parameter that can
C be overriden in the Makefile with the DEFINES macro or in CPP_OPTIONS.h
#ifndef CG2D_OUTERLOOPITERS
# define CG2D_OUTERLOOPITERS 10
#endif
#endif /* TARGET_NEC_SX */
CBOP
C !ROUTINE: CG2D_SR
C !INTERFACE:
SUBROUTINE CG2D_SR(
I cg2d_b,
U cg2d_x,
O firstResidual,
O lastResidual,
U numIters,
I myThid )
C !DESCRIPTION: \bv
C *==========================================================*
C | SUBROUTINE CG2D
C | o Two-dimensional grid problem conjugate-gradient
C | inverter (with preconditioner).
C *==========================================================*
C | Con. grad is an iterative procedure for solving Ax = b.
C | It requires the A be symmetric.
C | This implementation assumes A is a five-diagonal
C | matrix of the form that arises in the discrete
C | representation of the del^2 operator in a
C | two-dimensional space.
C | Notes:
C | ======
C | This implementation can support shared-memory
C | multi-threaded execution. In order to do this COMMON
C | blocks are used for many of the arrays - even ones that
C | are only used for intermedaite results. This design is
C | OK if you want to all the threads to collaborate on
C | solving the same problem. On the other hand if you want
C | the threads to solve several different problems
C | concurrently this implementation will not work.
C |
C | This version implements the single-reduction CG algorithm of
C | d Azevedo, Eijkhout, and Romine (Lapack Working Note 56, 1999).
C | C. Wolfe, November 2009, clwolfe@ucsd.edu
C *==========================================================*
C \ev
C !USES:
IMPLICIT NONE
C === Global data ===
#include "SIZE.h"
#include "EEPARAMS.h"
#include "PARAMS.h"
#include "CG2D.h"
c#include "GRID.h"
c#include "SURFACE.h"
C !INPUT/OUTPUT PARAMETERS:
C === Routine arguments ===
C myThid :: Thread on which I am working.
C cg2d_b :: The source term or "right hand side"
C cg2d_x :: The solution
C firstResidual :: the initial residual before any iterations
C lastResidual :: the actual residual reached
C numIters :: Entry: the maximum number of iterations allowed
C Exit: the actual number of iterations used
_RL cg2d_b(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RL cg2d_x(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RL firstResidual
_RL lastResidual
INTEGER numIters
INTEGER myThid
#ifdef ALLOW_SRCG
C !LOCAL VARIABLES:
C === Local variables ====
C actualIts :: Number of iterations taken
C actualResidual :: residual
C bi, bj :: Block index in X and Y.
C eta_qrN :: Used in computing search directions
C eta_qrNM1 suffix N and NM1 denote current and
C cgBeta previous iterations respectively.
C alpha
C sumRHS :: Sum of right-hand-side. Sometimes this is a
C useful debuggin/trouble shooting diagnostic.
C For neumann problems sumRHS needs to be ~0.
C or they converge at a non-zero residual.
C err :: Measure of residual of Ax - b, usually the norm.
C I, J, it2d :: Loop counters ( it2d counts CG iterations )
INTEGER actualIts
_RL actualResidual
INTEGER bi, bj
INTEGER I, J, it2d
_RL err, errTile(nSx,nSy)
_RL eta_qrN,eta_qrNtile(nSx,nSy)
_RL eta_qrNM1
_RL cgBeta
_RL alpha, alphaTile(nSx,nSy)
_RL sigma, sigmaTile(nSx,nSy)
_RL delta, deltaTile(nSx,nSy)
_RL sumRHS, sumRHStile(nSx,nSy)
_RL rhsMax
_RL rhsNorm
CHARACTER*(MAX_LEN_MBUF) msgBuf
LOGICAL printResidual
CEOP
C-- Initialise inverter
eta_qrNM1 = 1. _d 0
C-- Normalise RHS
rhsMax = 0. _d 0
DO bj=myByLo(myThid),myByHi(myThid)
DO bi=myBxLo(myThid),myBxHi(myThid)
DO J=1,sNy
DO I=1,sNx
cg2d_b(I,J,bi,bj) = cg2d_b(I,J,bi,bj)*cg2dNorm
rhsMax = MAX(ABS(cg2d_b(I,J,bi,bj)),rhsMax)
ENDDO
ENDDO
ENDDO
ENDDO
IF (cg2dNormaliseRHS) THEN
C- Normalise RHS :
_GLOBAL_MAX_RL( rhsMax, myThid )
rhsNorm = 1. _d 0
IF ( rhsMax .NE. 0. ) rhsNorm = 1. _d 0 / rhsMax
DO bj=myByLo(myThid),myByHi(myThid)
DO bi=myBxLo(myThid),myBxHi(myThid)
DO J=1,sNy
DO I=1,sNx
cg2d_b(I,J,bi,bj) = cg2d_b(I,J,bi,bj)*rhsNorm
cg2d_x(I,J,bi,bj) = cg2d_x(I,J,bi,bj)*rhsNorm
ENDDO
ENDDO
ENDDO
ENDDO
C- end Normalise RHS
ENDIF
C-- Update overlaps
CALL EXCH_XY_RL( cg2d_x, myThid )
C-- Initial residual calculation
err = 0. _d 0
sumRHS = 0. _d 0
DO bj=myByLo(myThid),myByHi(myThid)
DO bi=myBxLo(myThid),myBxHi(myThid)
DO J=1-1,sNy+1
DO I=1-1,sNx+1
cg2d_s(I,J,bi,bj) = 0.
ENDDO
ENDDO
sumRHStile(bi,bj) = 0. _d 0
errTile(bi,bj) = 0. _d 0
#ifdef TARGET_NEC_SX
!CDIR OUTERUNROLL=CG2D_OUTERLOOPITERS
#endif /* TARGET_NEC_SX */
DO J=1,sNy
DO I=1,sNx
cg2d_r(I,J,bi,bj) = cg2d_b(I,J,bi,bj) -
& (aW2d(I ,J ,bi,bj)*cg2d_x(I-1,J ,bi,bj)
& +aW2d(I+1,J ,bi,bj)*cg2d_x(I+1,J ,bi,bj)
& +aS2d(I ,J ,bi,bj)*cg2d_x(I ,J-1,bi,bj)
& +aS2d(I ,J+1,bi,bj)*cg2d_x(I ,J+1,bi,bj)
& +aC2d(I ,J ,bi,bj)*cg2d_x(I ,J ,bi,bj)
& )
errTile(bi,bj) = errTile(bi,bj)
& + cg2d_r(I,J,bi,bj)*cg2d_r(I,J,bi,bj)
sumRHStile(bi,bj) = sumRHStile(bi,bj) + cg2d_b(I,J,bi,bj)
ENDDO
ENDDO
ENDDO
ENDDO
CALL EXCH_S3D_RL( cg2d_r, 1, myThid )
CALL GLOBAL_SUM_TILE_RL( sumRHStile, sumRHS, myThid )
CALL GLOBAL_SUM_TILE_RL( errTile, err, myThid )
err = SQRT(err)
actualIts = 0
actualResidual = err
printResidual = .FALSE.
IF ( debugLevel .GE. debLevZero ) THEN
_BEGIN_MASTER( myThid )
printResidual = printResidualFreq.GE.1
WRITE(standardmessageunit,'(A,1P2E22.14)')
& ' cg2d: Sum(rhs),rhsMax = ', sumRHS,rhsMax
_END_MASTER( myThid )
ENDIF
firstResidual=actualResidual
IF ( err .LT. cg2dTolerance ) GOTO 11
C DER (1999) do one iteration outside of the loop to start things up.
C-- Solve preconditioning equation and update
C-- conjugate direction vector "s".
eta_qrN = 0. _d 0
DO bj=myByLo(myThid),myByHi(myThid)
DO bi=myBxLo(myThid),myBxHi(myThid)
eta_qrNtile(bi,bj) = 0. _d 0
#ifdef TARGET_NEC_SX
!CDIR OUTERUNROLL=CG2D_OUTERLOOPITERS
#endif /* TARGET_NEC_SX */
DO J=1,sNy
DO I=1,sNx
cg2d_y(I,J,bi,bj) =
& pC(I ,J ,bi,bj)*cg2d_r(I ,J ,bi,bj)
& +pW(I ,J ,bi,bj)*cg2d_r(I-1,J ,bi,bj)
& +pW(I+1,J ,bi,bj)*cg2d_r(I+1,J ,bi,bj)
& +pS(I ,J ,bi,bj)*cg2d_r(I ,J-1,bi,bj)
& +pS(I ,J+1,bi,bj)*cg2d_r(I ,J+1,bi,bj)
cg2d_s(I,J,bi,bj) = cg2d_y(I,J,bi,bj)
eta_qrNtile(bi,bj) = eta_qrNtile(bi,bj)
& +cg2d_y(I,J,bi,bj)*cg2d_r(I,J,bi,bj)
ENDDO
ENDDO
ENDDO
ENDDO
CALL EXCH_S3D_RL( cg2d_s, 1, myThid )
CALL GLOBAL_SUM_TILE_RL( eta_qrNtile,eta_qrN,myThid )
eta_qrNM1 = eta_qrN
C== Evaluate laplace operator on conjugate gradient vector
C== q = A.s
alpha = 0. _d 0
DO bj=myByLo(myThid),myByHi(myThid)
DO bi=myBxLo(myThid),myBxHi(myThid)
alphaTile(bi,bj) = 0. _d 0
#ifdef TARGET_NEC_SX
!CDIR OUTERUNROLL=CG2D_OUTERLOOPITERS
#endif /* TARGET_NEC_SX */
DO J=1,sNy
DO I=1,sNx
cg2d_q(I,J,bi,bj) =
& aW2d(I ,J ,bi,bj)*cg2d_s(I-1,J ,bi,bj)
& +aW2d(I+1,J ,bi,bj)*cg2d_s(I+1,J ,bi,bj)
& +aS2d(I ,J ,bi,bj)*cg2d_s(I ,J-1,bi,bj)
& +aS2d(I ,J+1,bi,bj)*cg2d_s(I ,J+1,bi,bj)
& +aC2d(I ,J ,bi,bj)*cg2d_s(I ,J ,bi,bj)
alphaTile(bi,bj) = alphaTile(bi,bj)
& + cg2d_s(I,J,bi,bj)*cg2d_q(I,J,bi,bj)
ENDDO
ENDDO
ENDDO
ENDDO
CALL GLOBAL_SUM_TILE_RL( alphaTile, alpha, myThid )
sigma = eta_qrN/alpha
C== Update solution and residual vectors
C Now compute "interior" points.
DO bj=myByLo(myThid),myByHi(myThid)
DO bi=myBxLo(myThid),myBxHi(myThid)
errTile(bi,bj) = 0. _d 0
DO J=1,sNy
DO I=1,sNx
cg2d_x(I,J,bi,bj)=cg2d_x(I,J,bi,bj)+sigma*cg2d_s(I,J,bi,bj)
cg2d_r(I,J,bi,bj)=cg2d_r(I,J,bi,bj)-sigma*cg2d_q(I,J,bi,bj)
ENDDO
ENDDO
ENDDO
ENDDO
CALL EXCH_S3D_RL( cg2d_r,1, myThid )
C >>>>>>>>>>>>>>> BEGIN SOLVER <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
DO 10 it2d=1, numIters
C-- Solve preconditioning equation and update
C-- conjugate direction vector "s".
C-- z = M^-1 r
DO bj=myByLo(myThid),myByHi(myThid)
DO bi=myBxLo(myThid),myBxHi(myThid)
#ifdef TARGET_NEC_SX
!CDIR OUTERUNROLL=CG2D_OUTERLOOPITERS
#endif /* TARGET_NEC_SX */
DO J=1,sNy
DO I=1,sNx
cg2d_y(I,J,bi,bj) =
& pC(I ,J ,bi,bj)*cg2d_r(I ,J ,bi,bj)
& +pW(I ,J ,bi,bj)*cg2d_r(I-1,J ,bi,bj)
& +pW(I+1,J ,bi,bj)*cg2d_r(I+1,J ,bi,bj)
& +pS(I ,J ,bi,bj)*cg2d_r(I ,J-1,bi,bj)
& +pS(I ,J+1,bi,bj)*cg2d_r(I ,J+1,bi,bj)
ENDDO
ENDDO
ENDDO
ENDDO
CALL EXCH_S3D_RL( cg2d_y, 1, myThid )
C== v = A.z
C-- eta_qr = <z,r>
C-- delta = <z,v>
C-- Do the error calcuation here to consolidate global reductions
eta_qrN = 0. _d 0
delta = 0. _d 0
err = 0. _d 0
DO bj=myByLo(myThid),myByHi(myThid)
DO bi=myBxLo(myThid),myBxHi(myThid)
eta_qrNtile(bi,bj) = 0. _d 0
deltaTile(bi,bj) = 0. _d 0
errTile(bi,bj) = 0. _d 0
#ifdef TARGET_NEC_SX
!CDIR OUTERUNROLL=CG2D_OUTERLOOPITERS
#endif /* TARGET_NEC_SX */
DO J=1,sNy
DO I=1,sNx
cg2d_v(I,J,bi,bj) =
& aW2d(I ,J ,bi,bj)*cg2d_y(I-1,J ,bi,bj)
& +aW2d(I+1,J ,bi,bj)*cg2d_y(I+1,J ,bi,bj)
& +aS2d(I ,J ,bi,bj)*cg2d_y(I ,J-1,bi,bj)
& +aS2d(I ,J+1,bi,bj)*cg2d_y(I ,J+1,bi,bj)
& +aC2d(I ,J ,bi,bj)*cg2d_y(I ,J ,bi,bj)
eta_qrNtile(bi,bj) = eta_qrNtile(bi,bj)
& +cg2d_y(I,J,bi,bj)*cg2d_r(I,J,bi,bj)
deltaTile(bi,bj) = deltaTile(bi,bj)
& +cg2d_y(I,J,bi,bj)*cg2d_v(I,J,bi,bj)
errTile(bi,bj) = errTile(bi,bj)
& + cg2d_r(I,J,bi,bj)*cg2d_r(I,J,bi,bj)
ENDDO
ENDDO
ENDDO
ENDDO
C CALL GLOBAL_SUM_TILE_RL( eta_qrNtile,eta_qrN,myThid )
C CALL GLOBAL_SUM_TILE_RL( deltaTile,delta,myThid )
C CALL GLOBAL_SUM_TILE_RL( errTile, err, myThid )
DO bj=myByLo(myThid),myByHi(myThid)
DO bi=myBxLo(myThid),myBxHi(myThid)
sumPhi(1,bi,bj) = eta_qrNtile(bi,bj)
sumPhi(2,bi,bj) = deltaTile(bi,bj)
sumPhi(3,bi,bj) = errTile(bi,bj)
ENDDO
ENDDO
C global_vec_sum_r8 does not call BAR2 on input
CALL BAR2( myThid)
CALL GLOBAL_VEC_SUM_R8(3,3,sumPhi,myThid)
eta_qrN = sumPhi(1,1,1)
delta = sumPhi(2,1,1)
err = sumPhi(3,1,1)
err = SQRT(err)
actualIts = it2d
actualResidual = err
IF ( printResidual ) THEN
IF ( MOD( it2d-1, printResidualFreq ).EQ.0 ) THEN
WRITE(msgBuf,'(A,I6,A,1PE21.14)')
& ' cg2d: iter=', actualIts, ' ; resid.= ', actualResidual
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT, myThid )
ENDIF
ENDIF
IF ( err .LT. cg2dTolerance ) GOTO 11
cgBeta = eta_qrN/eta_qrNM1
eta_qrNM1 = eta_qrN
alpha = delta - cgBeta**2*alpha
sigma = eta_qrN/alpha
DO bj=myByLo(myThid),myByHi(myThid)
DO bi=myBxLo(myThid),myBxHi(myThid)
DO J=1,sNy
DO I=1,sNx
cg2d_s(I,J,bi,bj) = cg2d_y(I,J,bi,bj)
& + cgBeta*cg2d_s(I,J,bi,bj)
cg2d_x(I,J,bi,bj) = cg2d_x(I,J,bi,bj)
& + sigma*cg2d_s(I,J,bi,bj)
cg2d_q(I,J,bi,bj) = cg2d_v(I,J,bi,bj)
& + cgBeta*cg2d_q(I,J,bi,bj)
cg2d_r(I,J,bi,bj) = cg2d_r(I,J,bi,bj)
& - sigma*cg2d_q(I,J,bi,bj)
ENDDO
ENDDO
ENDDO
ENDDO
CALL EXCH_S3D_RL( cg2d_r, 1, myThid )
10 CONTINUE
11 CONTINUE
IF (cg2dNormaliseRHS) THEN
C-- Un-normalise the answer
DO bj=myByLo(myThid),myByHi(myThid)
DO bi=myBxLo(myThid),myBxHi(myThid)
DO J=1,sNy
DO I=1,sNx
cg2d_x(I ,J ,bi,bj) = cg2d_x(I ,J ,bi,bj)/rhsNorm
ENDDO
ENDDO
ENDDO
ENDDO
ENDIF
C-- Return parameters to caller
lastResidual=actualResidual
numIters=actualIts
C The following exchange was moved up to solve_for_pressure
C for compatibility with TAMC.
C _EXCH_XY_R8(cg2d_x, myThid )
c _BEGIN_MASTER( myThid )
c WRITE(*,'(A,I6,1PE30.14)') ' CG2D iters, err = ',
c & actualIts, actualResidual
c _END_MASTER( myThid )
#endif /* ALLOW_SRCG */
RETURN
END
|
C $Header: /u/gcmpack/MITgcm/pkg/ptracers/ptracers_readparms.F,v 1.38 2010/12/13 20:27:15 jmc Exp $
C $Name: $
#include "PTRACERS_OPTIONS.h"
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
CBOP
C !ROUTINE: PTRACERS_READPARMS
C !INTERFACE:
SUBROUTINE PTRACERS_READPARMS( myThid )
C !DESCRIPTION:
C Initialize PTRACERS parameters, read in data.ptracers
C !USES:
IMPLICIT NONE
#include "SIZE.h"
#include "EEPARAMS.h"
#ifdef ALLOW_LONGSTEP
#include "LONGSTEP_PARAMS.h"
#endif
#include "PTRACERS_SIZE.h"
#include "PTRACERS_PARAMS.h"
#include "PARAMS.h"
#ifdef ALLOW_MNC
#include "MNC_PARAMS.h"
#endif
C !INPUT PARAMETERS:
INTEGER myThid
CEOP
#ifdef ALLOW_PTRACERS
C !FUNCTIONS
LOGICAL GAD_VALID_ADVSCHEME
EXTERNAL GAD_VALID_ADVSCHEME
C !LOCAL VARIABLES:
C k,iTracer :: loop indices
C iUnit :: unit number for I/O
C msgBuf :: message buffer
INTEGER k, iTracer
INTEGER iUnit
INTEGER ic
LOGICAL validNum
CHARACTER*(MAX_LEN_MBUF) msgBuf
_RL PTRACERS_diffKr(PTRACERS_num)
_RL tauTr1ClimRelax
C PTRACERS_taveFreq :: Frequency with which time-averaged PTRACERS
C are written to post-processing files.
C tauTr1ClimRelax :: old parameter (will be removed 1 day)
NAMELIST /PTRACERS_PARM01/
& tauTr1ClimRelax,
& PTRACERS_dumpFreq,
& PTRACERS_taveFreq,
& PTRACERS_monitorFreq,
& PTRACERS_advScheme,
& PTRACERS_ImplVertAdv,
& PTRACERS_diffKh,
& PTRACERS_diffK4,
& PTRACERS_diffKr,
& PTRACERS_diffKrNr,
& PTRACERS_ref,
& PTRACERS_EvPrRn,
& PTRACERS_addSrelax2EmP,
& PTRACERS_useGMRedi,
& PTRACERS_useDWNSLP,
& PTRACERS_useKPP,
& PTRACERS_Iter0,
& PTRACERS_numInUse,
& PTRACERS_initialFile,
& PTRACERS_useRecords,
& PTRACERS_names,
& PTRACERS_long_names,
& PTRACERS_units,
& PTRACERS_timeave_mnc,
& PTRACERS_snapshot_mnc,
& PTRACERS_monitor_mnc,
& PTRACERS_pickup_write_mnc,
& PTRACERS_pickup_read_mnc
_BEGIN_MASTER(myThid)
C This routine has been called by the main model so we set our
C internal flag to indicate we are in business
c PTRACERSisON=.TRUE.
C Note(jmc): remove this flag which is not really usefull (not set properly
C when usePTRACERS=F and always TRUE otherwise);
C much better to use "usePTRACERS" flag instead.
C Set ptracer IO & diagnostics labels (2 characters long)
CALL PTRACERS_SET_IOLABEL(
O PTRACERS_ioLabel,
I PTRACERS_num, myThid )
C Set defaults values for parameters in PTRACERS.h
PTRACERS_dumpFreq = dumpFreq
PTRACERS_taveFreq = taveFreq
PTRACERS_monitorFreq = monitorFreq
PTRACERS_Iter0 = 0
PTRACERS_numInUse=-1
DO iTracer=1,PTRACERS_num
PTRACERS_advScheme(iTracer)=saltAdvScheme
PTRACERS_ImplVertAdv(iTracer) = .FALSE.
PTRACERS_diffKh(iTracer)=diffKhS
PTRACERS_diffK4(iTracer)=diffK4S
PTRACERS_diffKr(iTracer)=UNSET_RL
DO k=1,Nr
PTRACERS_diffKrNr(k,iTracer)=diffKrNrS(k)
PTRACERS_ref (k,iTracer)=0. _d 0
ENDDO
PTRACERS_EvPrRn(iTracer)=UNSET_RL
PTRACERS_useGMRedi(iTracer)=useGMRedi
PTRACERS_useDWNSLP(iTracer)=useDOWN_SLOPE
PTRACERS_useKPP(iTracer) =useKPP
PTRACERS_initialFile(iTracer)=' '
DO ic = 1,MAX_LEN_FNAM
PTRACERS_names(iTracer)(ic:ic) = ' '
PTRACERS_long_names(iTracer)(ic:ic) = ' '
PTRACERS_units(iTracer)(ic:ic) = ' '
ENDDO
ENDDO
PTRACERS_addSrelax2EmP = .FALSE.
PTRACERS_useRecords = .FALSE.
#ifdef ALLOW_MNC
PTRACERS_timeave_mnc = useMNC .AND. timeave_mnc
PTRACERS_snapshot_mnc = useMNC .AND. snapshot_mnc
PTRACERS_monitor_mnc = useMNC .AND. monitor_mnc
PTRACERS_pickup_write_mnc = useMNC .AND. pickup_write_mnc
PTRACERS_pickup_read_mnc = useMNC .AND. pickup_read_mnc
#else
PTRACERS_timeave_mnc = .FALSE.
PTRACERS_snapshot_mnc = .FALSE.
PTRACERS_monitor_mnc = .FALSE.
PTRACERS_pickup_write_mnc = .FALSE.
PTRACERS_pickup_read_mnc = .FALSE.
#endif
tauTr1ClimRelax = 0.
DO k = 1,Nr
#ifdef ALLOW_LONGSTEP
PTRACERS_dTLev(k) = LS_nIter*dTtracerLev(k)
#else
PTRACERS_dTLev(k) = dTtracerLev(k)
#endif
ENDDO
C Open and read the data.ptracers file
WRITE(msgBuf,'(A)') ' PTRACERS_READPARMS: opening data.ptracers'
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT , myThid )
CALL OPEN_COPY_DATA_FILE(
I 'data.ptracers', 'PTRACERS_READPARMS',
O iUnit,
I myThid )
READ(UNIT=iUnit,NML=PTRACERS_PARM01)
WRITE(msgBuf,'(A)')
& ' PTRACERS_READPARMS: finished reading data.ptracers'
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
& SQUEEZE_RIGHT , myThid )
C Close the open data file
CLOSE(iUnit)
C Now set-up any remaining parameters that result from the input
C parameters
C Tracer 1 climatology relaxation time scale (<- but the code is gone !)
IF ( tauTr1ClimRelax .EQ. 0. ) THEN
lambdaTr1ClimRelax = 0.
ELSE
lambdaTr1ClimRelax = 1./tauTr1ClimRelax
ENDIF
C If PTRACERS_numInUse was not set in data.ptracers then we can
C assume that all PTRACERS fields will be in use
IF (PTRACERS_numInUse.LT.0) THEN
PTRACERS_numInUse=PTRACERS_num
ENDIF
C Check we are not trying to use more tracers than allowed
IF (PTRACERS_numInUse.GT.PTRACERS_num) THEN
WRITE(msgBuf,'(A,I4,A,I4,A)')
& ' PTRACERS_READPARMS: You requested',PTRACERS_numInUse,
& ' tracers at run time when only',PTRACERS_num,
& ' were specified at compile time. Naughty! '
CALL PRINT_ERROR( msgBuf, myThid )
STOP 'ABNORMAL END: S/R PTRACERS_READPARMS'
ENDIF
C Check for valid advection-scheme number
DO iTracer=1,PTRACERS_numInUse
validNum = GAD_VALID_ADVSCHEME( PTRACERS_advScheme(iTracer) )
IF ( .NOT.validNum ) THEN
WRITE(msgBuf,'(2A,I6)') 'PTRACERS_READPARMS: ',
& 'invalid advection scheme number=',PTRACERS_advScheme(iTracer)
CALL PRINT_ERROR( msgBuf, myThid )
WRITE(msgBuf,'(2A,I6)') 'PTRACERS_READPARMS: ',
& 'for tracer #', iTracer
CALL PRINT_ERROR( msgBuf, myThid )
STOP 'ABNORMAL END: S/R PTRACERS_READPARMS'
ENDIF
ENDDO
#ifndef INCLUDE_IMPLVERTADV_CODE
DO iTracer=1,PTRACERS_numInUse
IF ( PTRACERS_ImplVertAdv(iTracer) ) THEN
WRITE(msgBuf,'(A)')
& 'PTRACERS_READPARMS: #undef INCLUDE_IMPLVERTADV_CODE'
CALL PRINT_ERROR( msgBuf, myThid )
WRITE(msgBuf,'(2A,I3,A)') 'PTRACERS_READPARMS:',
& ' but pTracers_ImplVertAdv(',iTracer,' ) is TRUE'
CALL PRINT_ERROR( msgBuf, myThid )
STOP 'ABNORMAL END: S/R PTRACERS_READPARMS'
ENDIF
ENDDO
IF ( PTRACERS_dTLev(1).NE.PTRACERS_dTLev(Nr)
& .AND. implicitDiffusion ) THEN
WRITE(msgBuf,'(A)')
& 'PTRACERS_READPARMS: #undef INCLUDE_IMPLVERTADV_CODE'
CALL PRINT_ERROR( msgBuf , myThid)
WRITE(msgBuf,'(2A)') 'PTRACERS_READPARMS: ',
& 'but implicitDiffusion=T with non-uniform PTRACERS_dTLev'
CALL PRINT_ERROR( msgBuf , myThid)
STOP 'ABNORMAL END: S/R PTRACERS_READPARMS'
ENDIF
#endif
DO iTracer=1,PTRACERS_numInUse
IF ( PTRACERS_useGMRedi(iTracer) .AND. .NOT.useGMRedi ) THEN
WRITE(msgBuf,'(2A,I3,A)') 'PTRACERS_READPARMS:',
& ' pTracers_useGMRedi(',iTracer,' ) is TRUE'
CALL PRINT_ERROR( msgBuf, myThid )
WRITE(msgBuf,'(A,L5,A)')
& 'PTRACERS_READPARMS: But not useGMRedi (=',useGMRedi,')'
CALL PRINT_ERROR( msgBuf, myThid )
STOP 'ABNORMAL END: S/R PTRACERS_READPARMS'
ENDIF
IF ( PTRACERS_useDWNSLP(iTracer) .AND. .NOT.useDOWN_SLOPE ) THEN
WRITE(msgBuf,'(2A,I3,A)') 'PTRACERS_READPARMS:',
& ' pTracers_useDWNSLP(',iTracer,' ) is TRUE'
CALL PRINT_ERROR( msgBuf, myThid )
WRITE(msgBuf,'(2A,L5,A)') 'PTRACERS_READPARMS:',
& ' But not useDOWN_SLOPE (=', useDOWN_SLOPE, ')'
CALL PRINT_ERROR( msgBuf, myThid )
STOP 'ABNORMAL END: S/R PTRACERS_READPARMS'
ENDIF
IF ( PTRACERS_useKPP(iTracer) .AND. .NOT.useKPP ) THEN
WRITE(msgBuf,'(2A,I3,A)') 'PTRACERS_READPARMS:',
& ' pTracers_useKPP(',iTracer,' ) is TRUE'
CALL PRINT_ERROR( msgBuf, myThid )
WRITE(msgBuf,'(A,L5,A)')
& 'PTRACERS_READPARMS: But not useKPP (=',useKPP,')'
CALL PRINT_ERROR( msgBuf, myThid )
STOP 'ABNORMAL END: S/R PTRACERS_READPARMS'
ENDIF
IF ( PTRACERS_diffKr(iTracer).NE.UNSET_RL ) THEN
DO k=1,Nr
PTRACERS_diffKrNr(k,iTracer)=PTRACERS_diffKr(iTracer)
ENDDO
ENDIF
ENDDO
#ifdef ALLOW_MNC
PTRACERS_timeave_mnc = useMNC .AND. PTRACERS_timeave_mnc
PTRACERS_snapshot_mnc = useMNC .AND. PTRACERS_snapshot_mnc
PTRACERS_monitor_mnc = useMNC .AND. PTRACERS_monitor_mnc
PTRACERS_pickup_write_mnc = useMNC .AND. PTRACERS_pickup_write_mnc
PTRACERS_pickup_read_mnc = useMNC .AND. PTRACERS_pickup_read_mnc
PTRACERS_timeave_mdsio = (.NOT. PTRACERS_timeave_mnc)
& .OR. outputTypesInclusive
PTRACERS_snapshot_mdsio = (.NOT. PTRACERS_snapshot_mnc)
& .OR. outputTypesInclusive
PTRACERS_monitor_stdio = (.NOT. PTRACERS_monitor_mnc)
& .OR. outputTypesInclusive
PTRACERS_pickup_write_mdsio = (.NOT. PTRACERS_pickup_write_mnc)
& .OR. outputTypesInclusive
PTRACERS_pickup_read_mdsio = (.NOT. PTRACERS_pickup_read_mnc)
& .OR. outputTypesInclusive
#else
PTRACERS_timeave_mnc = .FALSE.
PTRACERS_snapshot_mnc = .FALSE.
PTRACERS_monitor_mnc = .FALSE.
PTRACERS_pickup_write_mnc = .FALSE.
PTRACERS_pickup_read_mnc = .FALSE.
PTRACERS_timeave_mdsio = .TRUE.
PTRACERS_snapshot_mdsio = .TRUE.
PTRACERS_monitor_stdio = .TRUE.
PTRACERS_pickup_write_mdsio = .TRUE.
PTRACERS_pickup_read_mdsio = .TRUE.
#endif
C-- Print a summary of pTracer parameter values:
iUnit = standardMessageUnit
WRITE(msgBuf,'(A)') '// ==================================='
CALL PRINT_MESSAGE( msgBuf, iUnit, SQUEEZE_RIGHT , myThid )
WRITE(msgBuf,'(A)') '// PTRACERS parameters '
CALL PRINT_MESSAGE( msgBuf, iUnit, SQUEEZE_RIGHT , myThid )
WRITE(msgBuf,'(A)') '// ==================================='
CALL PRINT_MESSAGE( msgBuf, iUnit, SQUEEZE_RIGHT , myThid )
CALL WRITE_0D_I( PTRACERS_numInUse, INDEX_NONE,
& 'PTRACERS_numInUse =',
& ' /* number of tracers */')
CALL WRITE_0D_I( PTRACERS_Iter0, INDEX_NONE,
& 'PTRACERS_Iter0 =',
& ' /* timestep number when tracers are initialized */')
CALL WRITE_0D_L( PTRACERS_addSrelax2EmP, INDEX_NONE,
& 'PTRACERS_addSrelax2EmP =','/* add Salt relaxation to EmP */')
CALL WRITE_1D_RL( PTRACERS_dTLev, Nr, INDEX_K,
& 'PTRACERS_dTLev =',
&' /* Ptracer timestep ( s ) */')
CALL WRITE_0D_RL(PTRACERS_dumpFreq, INDEX_NONE,
& 'PTRACERS_dumpFreq =',
& ' /* Frequency^-1 for snapshot output (s) */')
CALL WRITE_0D_RL(PTRACERS_taveFreq, INDEX_NONE,
& 'PTRACERS_taveFreq =',
& ' /* Frequency^-1 for time-Aver. output (s) */')
CALL WRITE_0D_L( PTRACERS_useRecords, INDEX_NONE,
& 'PTRACERS_useRecords =', ' /* all tracers in 1 file */')
CALL WRITE_0D_L( PTRACERS_timeave_mnc, INDEX_NONE,
& 'PTRACERS_timeave_mnc =',
& ' /* use MNC for Tave output */')
CALL WRITE_0D_L( PTRACERS_snapshot_mnc, INDEX_NONE,
& 'PTRACERS_snapshot_mnc =',
& ' /* use MNC for snapshot output */')
CALL WRITE_0D_L( PTRACERS_pickup_write_mnc, INDEX_NONE,
& 'PTRACERS_pickup_write_mnc =',
& ' /* use MNC for writing pickups */')
CALL WRITE_0D_L( PTRACERS_pickup_read_mnc, INDEX_NONE,
& 'PTRACERS_pickup_read_mnc =',
& ' /* use MNC for reading pickups */')
DO iTracer=1,PTRACERS_numInUse
WRITE(msgBuf,'(A)') ' -----------------------------------'
CALL PRINT_MESSAGE( msgBuf, iUnit, SQUEEZE_RIGHT, myThid )
WRITE(msgBuf,'(A,I4)') ' tracer number : ',iTracer
CALL PRINT_MESSAGE( msgBuf, iUnit, SQUEEZE_RIGHT, myThid )
CALL WRITE_0D_C( PTRACERS_names(iTracer), -1, INDEX_NONE,
& 'PTRACERS_names =', ' /* Tracer short name */')
CALL WRITE_0D_C( PTRACERS_long_names(iTracer), -1, INDEX_NONE,
& 'PTRACERS_long_names =', ' /* Tracer long name */')
CALL WRITE_0D_C( PTRACERS_ioLabel(iTracer), 0, INDEX_NONE,
& 'PTRACERS_ioLabel =', ' /* tracer IO Label */')
CALL WRITE_0D_I( PTRACERS_advScheme(iTracer), INDEX_NONE,
& 'PTRACERS_advScheme =', ' /* Advection Scheme */')
CALL WRITE_0D_L( PTRACERS_ImplVertAdv(iTracer), INDEX_NONE,
& 'PTRACERS_ImplVertAdv =',
& ' /* implicit vert. advection flag */')
CALL WRITE_0D_RL( PTRACERS_diffKh(iTracer), INDEX_NONE,
& 'PTRACERS_diffKh =', ' /* Laplacian Diffusivity */')
CALL WRITE_0D_RL( PTRACERS_diffK4(iTracer), INDEX_NONE,
& 'PTRACERS_diffK4 =', ' /* Biharmonic Diffusivity */')
CALL WRITE_1D_RL( PTRACERS_diffKrNr(1,iTracer), Nr, INDEX_K,
& 'PTRACERS_diffKrNr =', ' /* Vertical Diffusivity */')
CALL WRITE_0D_L( PTRACERS_useGMRedi(iTracer), INDEX_NONE,
& 'PTRACERS_useGMRedi =', ' /* apply GM-Redi */')
CALL WRITE_0D_L( PTRACERS_useDWNSLP(iTracer), INDEX_NONE,
& 'PTRACERS_useDWNSLP =', ' /* apply DOWN-SLOPE Flow */')
CALL WRITE_0D_L( PTRACERS_useKPP(iTracer), INDEX_NONE,
& 'PTRACERS_useKPP =', ' /* apply KPP scheme */')
CALL WRITE_1D_RL( PTRACERS_ref(1,iTracer), Nr, INDEX_K,
& 'PTRACERS_ref =', ' /* Reference vertical profile */')
CALL WRITE_0D_RL( PTRACERS_EvPrRn(iTracer), INDEX_NONE,
& 'PTRACERS_EvPrRn =', '/* tracer conc. in Evap. & Rain */')
ENDDO
WRITE(msgBuf,'(A)') ' -----------------------------------'
CALL PRINT_MESSAGE( msgBuf, iUnit, SQUEEZE_RIGHT, myThid )
_END_MASTER(myThid)
C Everyone else must wait for the parameters to be loaded
_BARRIER
#endif /* ALLOW_PTRACERS */
RETURN
END
|
Subroutine Get_Loads(LocF,ValF,nLod,nQc1,nQc2,iCont,iOut)
Implicit Real(kind=8) (a-h,o-z)
!==========================================================================================
include 'Drill.h'
include 'Examples.h'
!==========================================================================================
Real*8 ValF
Dimension ValF(nLod)
integer LocF
Dimension LocF(nLod)
!-------------------------------------------- for Check with Quintic
SELECT CASE (nEx)
CASE (1) ! PALAZOTTO:c0=0: Ex_1
call Get_Loads_Pal(LocF,ValF,nLod,nQc1,nQc2,iCont,iOut)
CASE (2) ! PALAZOTTO:c0=0.01: Ex_2
if(bDrill) then ! PALAZOTTO:c0=0.01: Ex_2
call Get_Loads_Pal_D(LocF,ValF,nLod,nQc1,nQc2,iCont,iOut)
else
call Get_Loads_Pal(LocF,ValF,nLod,nQc1,nQc2,iCont,iOut)
endif
CASE (3) ! 2D Str. Cantilever-TipMom:Ex_3
call Get_Loads_Str(LocF,ValF,nLod,nQc1,nQc2,iCont,iOut)
CASE (4) ! 3D Curved CantilevLINMOD: Ex_4
! call Get_Loads_LIN(Qf,nQ,iOut)
CASE (5) ! 3D Curved Cantilev.Bathe: Ex_5
! call Get_Loads_Bat(Qf,nQ,iOut)
CASE (6) ! 2D Frame Buckling_Argyris:Ex_6
! call Get_Loads_ARG(Qf,nQ,iOut)
CASE (7:9) ! FALL THRO' other: Ex_7-10...
return
CASE (10) ! Hemisphere w/ hole Ex_10
call Get_Loads_Hem(LocF,ValF,nLod,nQc1,nQc2,iCont,iOut)
CASE (11) ! Scordelis Low: Ex_11
call Get_Loads_Sco(LocF,ValF,nLod,nQc1,nQc2,iCont,iOut)
CASE (12) ! 2D Str. Cantil-Tip Twist:Ex_12
if(bDrill) then
call Get_Loads_Str_TT_D
& (LocF,ValF,nLod,nQc1,nQc2,iCont,iOut)
else
call Get_Loads_Str_TT(LocF,ValF,nLod,nQc1,nQc2,iCont,iOut)
endif
CASE DEFAULT
return
END SELECT
! =======================================================
!-----------
return
end
|
SUBROUTINE F08JFF(N,D,E,INFO)
C MARK 16 RELEASE. NAG COPYRIGHT 1992.
C MARK 17 REVISED. IER-1652 (JUN 1995).
C .. Entry Points ..
ENTRY DSTERF(N,D,E,INFO)
C
C Purpose
C =======
C
C DSTERF computes all the eigenvalues of a real symmetric tridiagonal
C matrix T, using the Pal-Walker-Kahan root-free variants of the QL and
C QR algorithms.
C
C Arguments
C =========
C
C N (input) INTEGER
C The order of the matrix T. N >= 0.
C
C D (input/output) DOUBLE PRECISION array, dimension (N)
C On entry, the n diagonal elements of the tridiagonal matrix.
C On exit, if INFO = 0, the eigenvalues in ascending order.
C
C E (input/output) DOUBLE PRECISION array, dimension (N-1)
C On entry, the n-1 subdiagonal elements of the tridiagonal
C matrix.
C On exit, E has been overwritten.
C
C INFO (output) INTEGER
C = 0: successful exit.
C < 0: if INFO = -i, the i-th argument had an illegal value.
C > 0: the algorithm has failed to find all the eigenvalues in
C a total of 30*N iterations; if INFO = i, then i elements
C of E have not converged to zero.
C
C -- LAPACK routine (adapted for NAG Library)
C Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
C Courant Institute, Argonne National Lab, and Rice University
C
C =====================================================================
C
C .. Parameters ..
DOUBLE PRECISION ZERO, ONE, TWO
PARAMETER (ZERO=0.0D0,ONE=1.0D0,TWO=2.0D0)
INTEGER MAXIT
PARAMETER (MAXIT=30)
C .. Scalar Arguments ..
INTEGER INFO, N
C .. Array Arguments ..
DOUBLE PRECISION D(*), E(*)
C .. Local Scalars ..
DOUBLE PRECISION ALPHA, BB, C, EPS, GAMMA, OLDC, OLDGAM, P, R,
* RT1, RT2, RTE, S, SIGMA
INTEGER I, ITN, J, K, L, LL, M, MM
C .. External Functions ..
DOUBLE PRECISION F06BNF, X02AJF
EXTERNAL F06BNF, X02AJF
C .. External Subroutines ..
EXTERNAL F06AAZ, F08JEX
C .. Intrinsic Functions ..
INTRINSIC ABS, SIGN, SQRT
C .. Executable Statements ..
C
C Test the input parameters.
C
INFO = 0
IF (N.LT.0) THEN
INFO = -1
CALL F06AAZ('F08JFF/DSTERF',-INFO)
RETURN
END IF
C
C Quick return if possible
C
IF (N.EQ.0) RETURN
C
C Determine the unit roundoff for this environment.
C
EPS = X02AJF()
C
C Square the elements of E.
C
DO 20 I = 1, N - 1
E(I) = E(I)*E(I)
20 CONTINUE
C
ITN = N*MAXIT
MM = 0
C
40 CONTINUE
C
C Determine where the matrix splits and choose QL or QR iteration
C for each block, according to whether top or bottom diagonal
C element is smaller.
C
LL = MM + 1
IF (LL.GT.N) GO TO 300
IF (LL.GT.1) E(LL-1) = ZERO
DO 60 MM = LL, N - 1
IF (SQRT(E(MM)).LE.EPS*SQRT(ABS(D(MM)))*SQRT(ABS(D(MM+1))))
* GO TO 80
60 CONTINUE
80 CONTINUE
C
IF (ABS(D(LL)).LE.ABS(D(MM))) THEN
C
C Perform QL iterations on rows and columns LL to MM;
C unconverged eigenvalues are in rows and columns L to MM.
C
L = LL
100 CONTINUE
IF (L.GT.MM) GO TO 40
C
C Look for small offdiagonal element.
C
DO 120 M = L, MM - 1
IF (SQRT(E(M)).LE.EPS*SQRT(ABS(D(M)))*SQRT(ABS(D(M+1))))
* GO TO 140
120 CONTINUE
140 CONTINUE
IF (M.NE.N) E(M) = ZERO
C
IF (M.GT.L+1) THEN
C
C Perform QL iteration on rows and columns L to M.
C
ITN = ITN - 1
IF (ITN.LT.0) GO TO 260
C
C Form shift.
C
P = D(L)
RTE = SQRT(E(L))
SIGMA = (D(L+1)-P)/(TWO*RTE)
R = F06BNF(SIGMA,ONE)
SIGMA = P - (RTE/(SIGMA+SIGN(R,SIGMA)))
C
C Inner loop.
C
C = ONE
S = ZERO
GAMMA = D(M) - SIGMA
P = GAMMA*GAMMA
DO 160 I = M - 1, L, -1
BB = E(I)
R = P + BB
IF (I.NE.M-1) E(I+1) = S*R
OLDC = C
C = P/R
S = BB/R
OLDGAM = GAMMA
ALPHA = D(I)
GAMMA = C*(ALPHA-SIGMA) - S*OLDGAM
D(I+1) = OLDGAM + (ALPHA-GAMMA)
IF (C.NE.ZERO) THEN
P = (GAMMA*GAMMA)/C
ELSE
P = OLDC*BB
END IF
160 CONTINUE
E(L) = S*P
D(L) = SIGMA + GAMMA
C
ELSE
IF (M.EQ.L+1) THEN
C
C If remaining matrix is 2 by 2, use F08JEX to compute its
C eigensystem.
C
CALL F08JEX(D(L),SQRT(E(L)),D(L+1),RT1,RT2)
D(L) = RT1
D(L+1) = RT2
E(L) = ZERO
END IF
L = M + 1
END IF
GO TO 100
C
ELSE
C
C Perform QR iterations on rows and columns LL to MM;
C unconverged eigenvalues are in rows and columns LL to M.
C
M = MM
180 CONTINUE
IF (M.LT.LL) GO TO 40
C
C Look for small offdiagonal element.
C
DO 200 L = M, LL + 1, -1
IF (SQRT(E(L-1)).LE.EPS*SQRT(ABS(D(L)))*SQRT(ABS(D(L-1))))
* GO TO 220
200 CONTINUE
220 CONTINUE
IF (L.NE.1) E(L-1) = ZERO
C
IF (L.LT.M-1) THEN
C
C Perform QR iteration on rows and columns L to M.
C
ITN = ITN - 1
IF (ITN.LT.0) GO TO 260
C
C Form shift.
C
P = D(M)
RTE = SQRT(E(M-1))
SIGMA = (D(M-1)-P)/(TWO*RTE)
R = F06BNF(SIGMA,ONE)
SIGMA = P - (RTE/(SIGMA+SIGN(R,SIGMA)))
C
C Inner loop.
C
C = ONE
S = ZERO
GAMMA = D(L) - SIGMA
P = GAMMA*GAMMA
DO 240 I = L, M - 1
BB = E(I)
R = P + BB
IF (I.NE.L) E(I-1) = S*R
OLDC = C
C = P/R
S = BB/R
OLDGAM = GAMMA
ALPHA = D(I+1)
GAMMA = C*(ALPHA-SIGMA) - S*OLDGAM
D(I) = OLDGAM + (ALPHA-GAMMA)
IF (C.NE.ZERO) THEN
P = (GAMMA*GAMMA)/C
ELSE
P = OLDC*BB
END IF
240 CONTINUE
E(M-1) = S*P
D(M) = SIGMA + GAMMA
C
ELSE
IF (L.EQ.M-1) THEN
C
C If remaining matrix is 2 by 2, use F08JEX to compute its
C eigenvalues.
C
CALL F08JEX(D(M-1),SQRT(E(M-1)),D(M),RT1,RT2)
D(M-1) = RT1
D(M) = RT2
E(M-1) = ZERO
END IF
M = L - 1
END IF
GO TO 180
C
END IF
C
260 CONTINUE
C
C Failure to converge.
C
DO 280 I = 1, N - 1
IF (E(I).NE.ZERO) INFO = INFO + 1
280 CONTINUE
RETURN
C
300 CONTINUE
C
C Order eigenvalues.
C
DO 340 I = 1, N - 1
K = I
P = D(I)
DO 320 J = I + 1, N
IF (D(J).LT.P) THEN
K = J
P = D(J)
END IF
320 CONTINUE
IF (K.NE.I) THEN
D(K) = D(I)
D(I) = P
END IF
340 CONTINUE
C
RETURN
C
C End of F08JFF (DSTERF)
C
END
|
c---------------------------------------------------------------------
c---------------------------------------------------------------------
subroutine adi(rhs,qs,square,forcing,ws,u,vs,us,
> rho_i,speed,IMAXP,JMAXP,KMAX)
c---------------------------------------------------------------------
c---------------------------------------------------------------------
integer IMAXP, JMAXP, KMAX
double precision
> us ( 0:IMAXP, 0:JMAXP, 0:KMAX-1),
> vs ( 0:IMAXP, 0:JMAXP, 0:KMAX-1),
> ws ( 0:IMAXP, 0:JMAXP, 0:KMAX-1),
> qs ( 0:IMAXP, 0:JMAXP, 0:KMAX-1),
> rho_i ( 0:IMAXP, 0:JMAXP, 0:KMAX-1),
> square ( 0:IMAXP, 0:JMAXP, 0:KMAX-1),
> speed ( 0:IMAXP, 0:JMAXP, 0:KMAX-1),
> forcing (5, 0:IMAXP, 0:JMAXP, 0:KMAX-1),
> u (5, 0:IMAXP, 0:JMAXP, 0:KMAX-1),
> rhs (5, 0:IMAXP, 0:JMAXP, 0:KMAX-1)
call compute_rhs(rhs,qs,square,speed,forcing,ws,u,vs,us,rho_i)
call txinvr(rhs,qs,square,speed,forcing,ws,u,vs,us,rho_i)
call x_solve(rho_i, u, qs, us, square, speed, rhs)
call y_solve(rho_i, u, qs, square, rhs, vs, speed)
call z_solve(u, qs, square, rhs, rho_i,forcing,ws,vs,us,speed)
call add(u, rhs)
return
end
|
C $Header: /u/gcmpack/MITgcm/pkg/seaice/seaice_ad_dump.F,v 1.6 2009/08/27 18:00:01 jmc Exp $
C $Name: $
#include "AD_CONFIG.h"
#include "PACKAGES_CONFIG.h"
#include "SEAICE_OPTIONS.h"
CBOP
C !ROUTINE: seaice_ad_dump
C !INTERFACE:
subroutine seaice_ad_dump( mytime, myiter, myThid )
C !DESCRIPTION: \bv
C *==========================================================*
C | SUBROUTINE seaice_ad_dump |
C *==========================================================*
C Extract adjoint variable from TAMC/TAF-generated
C adjoint common blocks, contained in adcommon.h
C and write fields to file;
C Make sure common blocks in adcommon.h are up-to-date
C w.r.t. current adjoint code.
C *==========================================================*
C | SUBROUTINE seaice_ad_dump |
C *==========================================================*
C \ev
C !USES:
IMPLICIT NONE
C == Global variables ===
#include "SIZE.h"
#include "EEPARAMS.h"
#include "PARAMS.h"
#include "SEAICE_PARAMS.h"
#ifdef ALLOW_MNC
#include "MNC_PARAMS.h"
#endif
#include "GRID.h"
#ifdef ALLOW_AUTODIFF_MONITOR
# include "adcommon.h"
#endif
LOGICAL DIFFERENT_MULTIPLE
EXTERNAL DIFFERENT_MULTIPLE
INTEGER IO_ERRCOUNT
EXTERNAL IO_ERRCOUNT
C !INPUT/OUTPUT PARAMETERS:
C == Routine arguments ==
C myIter - iteration counter for this thread
C myTime - time counter for this thread
C myThid - Thread number for this instance of the routine.
integer myThid
integer myiter
_RL mytime
#if (defined (ALLOW_ADJOINT_RUN) || defined (ALLOW_ADMTLM))
#ifdef ALLOW_AUTODIFF_MONITOR
C !LOCAL VARIABLES:
c == local variables ==
C suff - Hold suffix part of a filename
C beginIOErrCount - Begin and end IO error counts
C endIOErrCount
C msgBuf - Error message buffer
CHARACTER*(MAX_LEN_FNAM) suff
INTEGER beginIOErrCount
INTEGER endIOErrCount
CHARACTER*(MAX_LEN_MBUF) msgBuf
c == end of interface ==
CEOP
call TIMER_START('I/O (WRITE) [ADJOINT LOOP]', myThid )
IF (
& DIFFERENT_MULTIPLE(adjDumpFreq,mytime,deltaTClock)
& ) THEN
C-- Set suffix for this set of data files.
WRITE(suff,'(I10.10)') myIter
writeBinaryPrec = writeStatePrec
C-- Read IO error counter
beginIOErrCount = IO_ERRCOUNT(myThid)
CALL WRITE_REC_3D_RL(
& 'ADJarea.'//suff, writeBinaryPrec,
& 1, adarea, 1, myIter, myThid )
CALL WRITE_REC_3D_RL(
& 'ADJheff.'//suff, writeBinaryPrec,
& 1, adheff, 1, myIter, myThid )
CALL WRITE_REC_3D_RL(
& 'ADJhsnow.'//suff, writeBinaryPrec,
& 1, adhsnow, 1, myIter, myThid )
# ifdef SEAICE_ALLOW_DYNAMICS
cph IF ( SEAICEuseDynamics ) THEN
CALL WRITE_REC_3D_RL(
& 'ADJuice.'//suff, writeBinaryPrec,
& 1, aduice, 1, myIter, myThid )
CALL WRITE_REC_3D_RL(
& 'ADJvice.'//suff, writeBinaryPrec,
& 1, advice, 1, myIter, myThid )
cph ENDIF
# endif
#ifdef ALLOW_MNC
IF (useMNC .AND. autodiff_mnc) THEN
CALL MNC_CW_SET_UDIM('adseaice', -1, myThid)
CALL MNC_CW_RL_W_S('D','adseaice',0,0,'T',myTime,myThid)
CALL MNC_CW_SET_UDIM('adseaice', 0, myThid)
CALL MNC_CW_I_W_S('I','adseaice',0,0,'iter',myIter,myThid)
CALL MNC_CW_RL_W_S('D','adseaice',0,0,'model_time',myTime,
& myThid)
c
CALL MNC_CW_RL_W('D','adseaice',0,0,'adarea',
& adarea, myThid)
CALL MNC_CW_RL_W('D','adseaice',0,0,'adheff',
& adheff, myThid)
CALL MNC_CW_RL_W('D','adseaice',0,0,'adhsnow',
& adhsnow, myThid)
# ifdef SEAICE_ALLOW_DYNAMICS
IF (SEAICEuseDYNAMICS) THEN
CALL MNC_CW_RL_W('D','adseaice',0,0,'aduice',
& aduice, myThid)
CALL MNC_CW_RL_W('D','adseaice',0,0,'advice',
& advice, myThid)
ENDIF
# endif
ENDIF
#endif /* ALLOW_MNC */
ENDIF
CALL TIMER_STOP( 'I/O (WRITE) [ADJOINT LOOP]', myThid )
#endif /* ALLOW_AUTODIFF_MONITOR */
#endif /* ALLOW_ADJOINT_RUN */
RETURN
END
|
SUBROUTINE CFEER4
C
C CFEER4 OBTAINS THE EIGENVALUES AND EIGENVECTORS FROM THE
C REDUCED TRIDIAGONAL MATRIX FOR THE COMPLEX FEER METHOD
C
LOGICAL NO B ,DECREM ,QPR ,LZ(1) ,
1 DPMACH
INTEGER NAME(2) ,IZ(1) ,EOR
INTEGER WRTREW
DOUBLE PRECISION LAMBDA ,EPS ,DZ(1) ,D(4) ,
1 LAM1(2)
DIMENSION S(8) ,DMP1(2) ,ALAM(2) ,DM(2) ,
1 STATUS(2),ACCEPT(2),REJECT(2)
CHARACTER UFM*23 ,UWM*25 ,UIM*29
COMMON /XMSSG / UFM ,UWM ,UIM
COMMON /FEERAA/ IKMB(21) ,ILAM(7) ,IPHI(7) ,IDMPFL ,
1 ISCR(11) ,DUMAA(84),MCBVEC(7)
COMMON /FEERXC/ LAMBDA(2),SWDUM ,MREDUC ,NORD ,
1 IDIAG ,EPS ,NORTHO ,NORD2 ,
2 NORD4 ,NORDP1 ,NSWP(2) ,NO B ,
3 IT ,TEN2MT ,TENMHT ,NSTART ,
4 QPR ,JREG ,NOREG ,NZERO ,
5 TENMTT ,MINOPN
COMMON /ZZZZZZ/ Z(1)
COMMON /UNPAKX/ IPRC ,II ,NN ,INCR
COMMON /SYSTEM/ KSYSTM(65)
COMMON /NAMES / RD ,RDREW ,WRT ,WRTREW ,
1 REW ,NOREW ,EOFNRW
EQUIVALENCE (KSYSTM(2 ),NOUT ) ,(NROW,MREDUC) ,
1 (KSYSTM(55),IPREC) ,(D(1),S(1) ) ,
2 (Z(1),IZ(1),LZ(1),DZ(1))
DATA NAME / 4HCFEE,4HR4 /
DATA ACCEPT, REJECT/4H AC,4HCEPT,4H -RE,4HJECT /
C
C CORE ALLOCATION FOR ALLMAT
C
C CONTENTS SIZE POINTER TYPE NAME
C -------- ---- ------- ---- ----
C INPUT MATRIX--VECTORS 2*NROW*NROW IA COMP A
C EIGENVALUES 2*NROW IL COMP LAM
C H MATRIX 2*NROW*NROW IH COMP H
C HL MATRIX 2*NROW*NROW IHL COMP HL
C VECTOR STORAGE 2*NROW IV COMP VEC
C MULTIPLIERS 2*NROW IM COMP MULT
C INTH NROW INTH INTG INTH
C INTQ NROW INTQ LOGL INTQ
C
C CORE ALLOCATION AFTER ALLMAT IS FINISHED
C
C ALLMAT OUTPUT EIGENVECTORS IA
C EIGENVALUES IL
C ORDER OF EXTRACTION IH
C THEORETICAL ERRORS IHL
C NOT USED IV,IM
C STATUS OF SOLUTIONS INTH
C DISTANCES FROM CENTER INTQ
C VARIABLE PRECISION PHYSICAL EIGENVECTORS IV1
C VARIABLE PRECISION ORTHOGONAL VECTORS IV2
C
C DEFINITION OF INTERNAL PARAMETERS
C
C DMP1 = D-SUB-M-PLUS-1 = EXTRANEOUS OFF-DIAGONAL ELEMENT
C OF REDUCED TRIDIAGONAL MATRIX, USED FOR COMPUTING
C THEORETICAL ERRORS
C DM = FINAL OFF-DIAGONAL ELEMENT OF REDUCED TRIDIAGONAL
C MATRIX
C NO B = LOGICAL INDICATOR FOR ABSENCE OF DAMPING MATRIX B
C DECREM = LOGICAL INDICATOR FOR DECREMENTED SIZE OF REDUCED
C PROBLEM
C NROW = SIZE OF THE REDUCED PROBLEM (EQUIVALENT TO MREDUC)
C RMS = ROOT-MEAN-SQUARE OF EIGENVALUES, USED IN RIGID-BODY
C ERROR TEST
C NOTE.....SEE LISTING OF CFCNTL FOR ADDITIONAL DEFINITIONS
C
IF (QPR) WRITE (NOUT,600)
DPMACH = IPREC .EQ. 2
NORD8 = 2*NORD4
DECREM = .FALSE.
4 NROW2 = 2*NROW
NROWSQ = NROW*NROW2
C
C ALLOCATE CORE FOR ALLMAT
C
IA = 1
IL = IA + NROWSQ
IH = IL + NROW2
IHL = IH + NROWSQ
IV = IHL + NROWSQ
IM = IV + NROW2
INTH= IM + NROW2
INTQ= INTH+ NROW
C
C ALLOCATE CORE FOR PHYSICAL EIGENVECTORS (LEFT FOLLOWS RIGHT)
C
IV1 = INTQ + NROW
IV2 = IV1 + NORD8
IF (DPMACH .AND. MOD(IV2,2).EQ.0) IV2 = IV2 + 1
IV1X = IV1 - 1
C
C TEST FOR INSUFFICIENT CORE
C
NZ = KORSZ(Z(1))
IBUF1 = NZ - KSYSTM(1)
IBUF2 = IBUF1 - KSYSTM(1)
IOPN = IBUF2 - (IV2 + NORD8)
IF (IDIAG .NE. 0) WRITE (NOUT,610) IOPN
IF (IOPN .LE. 0) CALL MESAGE (-8,0,NAME(1))
IF (IOPN .LT. MINOPN) MINOPN = IOPN
IF (NSWP(2) .LT. 0) GO TO 209
C
C CONSTRUCT REDUCED TRIDIAGONAL MATRIX
C
DO 10 I = IA,IL
10 Z(I) = 0.
NROW22 = NROW2 + 2
CALL GOPEN (ISCR(5),Z(IBUF1),RDREW)
NW = 4*IPREC
EOR = 1
M = 0
NROW1 = NROW - 1
C
C ENTER LOOP
C
DO 20 I = 1,NROW
I1 = I - 1
CALL READ (*420,*430,ISCR(5),S(1),NW,EOR,M)
IF (QPR .AND. .NOT.DPMACH) WRITE (NOUT,620) I,(S(J),J=1,4)
IF (QPR .AND. DPMACH) WRITE (NOUT,630) I,(D(J),J=1,4)
C
C ALLMAT ACCEPTS ONLY SINGLE PRECISION ARRAY
C
J = IA + NROW22*I1
IF (.NOT.DPMACH) GO TO 15
C
C LOAD MAIN DIAGONAL ELEMENT
C
Z(J ) = D(3)
Z(J+1) = D(4)
IF (I .NE. NROW1) GO TO 12
C
C SAVE LAST OFF-DIAGONAL ELEMENT
C
DM(1) = D(1)
DM(2) = D(2)
12 IF (I .EQ. NROW) GO TO 20
C
C LOAD OFF-DIAGONAL ELEMENTS
C
Z(J+2) = D(1)
Z(J+3) = D(2)
J = J + NROW2
Z(J ) = D(1)
Z(J+1) = D(2)
GO TO 20
C
C LOAD MAIN DIAGONAL ELEMENT
C
15 Z(J ) = S(3)
Z(J+1) = S(4)
IF (I .NE. NROW1) GO TO 16
C
C SAVE LAST OFF-DIAGONAL ELEMENT
C
DM(1) = S(1)
DM(2) = S(2)
16 IF (I .EQ. NROW) GO TO 20
C
C LOAD OFF-DIAGONAL ELEMENTS
C
Z(J+2) = S(1)
Z(J+3) = S(2)
J = J + NROW2
Z(J ) = S(1)
Z(J+1) = S(2)
20 CONTINUE
C
C SAVE ERROR ELEMENT FROM TRIDIAGONAL MATRIX
C
IF (.NOT.DPMACH) GO TO 25
DMP1(1) = D(1)
DMP1(2) = D(2)
GO TO 26
25 DMP1(1) = S(1)
DMP1(2) = S(2)
26 CONTINUE
IF (QPR) WRITE (NOUT,640) (Z(I),I=1,NROWSQ)
CALL CLOSE (ISCR(5),REW)
IF (DECREM) GO TO 30
C
C DECREMENT THE REDUCED PROBLEM SIZE IF THE ERROR ELEMENT IS NULL
C
IF (DMP1(1).NE.0. .OR. DMP1(2).NE.0.) GO TO 30
MREDUC = MREDUC - 1
WRITE (NOUT,570) UWM,MREDUC
IF (MREDUC .EQ. 0) GO TO 440
IF (DM(1).NE.0. .OR. DM(2).NE.0.) GO TO 29
C
C NEW ERROR ELEMENT IS ALSO NULL. RESTORE ORIGINAL REDUCED SIZE.
C
MREDUC = MREDUC + 1
DMP1(1) = SNGL(EPS)
WRITE (NOUT,590) UWM,MREDUC,DMP1
GO TO 30
29 DECREM = .TRUE.
GO TO 4
C
30 CALL ALLMAT (Z(IA),Z(IL),Z(IH),Z(IHL),Z(IV),Z(IM),Z(INTH),Z(INTQ),
1 NROW,NROW,INIDUM)
C
C --------------- SPECIAL PRINT -------------------------
C
IF (.NOT.QPR) GO TO 4429
WRITE (NOUT,4408)
4408 FORMAT (1H0,10X,15HALLMAT EXECUTED,/,1H0)
J = IH - 1
WRITE (NOUT,4420) (Z(I),I=IL,J)
4420 FORMAT (1H0,11HEIGENVALUES, //,(1H ,2E16.8))
WRITE (NOUT,4422)
4422 FORMAT (1H0,12HEIGENVECTORS,//)
DO 4428 I = 1,NROW
L = IA + NROW2*(I-1)
K = L + NROW2 - 1
WRITE (NOUT,4424) (Z(J),J=L,K)
C
C CHECK NORMALITY
C
SUMR = 0.
SUMI = 0.
DO 7760 J = L,K,2
JJ = J + 1
SUMR = SUMR + Z(J)**2 - Z(JJ)**2
7760 SUMI = SUMI + 2.*Z(J)*Z(JJ)
WRITE (NOUT,7770) SUMR,SUMI
7770 FORMAT (//,35H SELF INNER-PRODUCT OF ABOVE VECTOR, /,1H ,6X,
1 11HREAL PART =,E16.8,8X,16HIMAGINARY PART =,E16.8)
4424 FORMAT (//,(1H ,6E16.8))
4428 CONTINUE
4429 CONTINUE
C -------------------------------------------------------
C
C NORMALIZE THE EIGENVECTORS OUTPUT FROM ALLMAT
C
IF (QPR) WRITE (NOUT,4422)
DO 36 I = 1,NROW
L = IA + NROW2*(I-1)
K = L + NROW2 - 1
SUMR = 0.
SUMI = 0.
DO 33 J = L,K,2
JJ = J + 1
SUMR = SUMR + Z(J)**2 - Z(JJ)**2
33 SUMI = SUMI + 2.*Z(J)*Z(JJ)
RSQRT= SQRT(SQRT(SUMR**2 + SUMI**2))
IF (RSQRT .GT. 0.) GO TO 34
WRITE (NOUT,560) UWM,NAME
GO TO 36
34 THETA2= .5*ATAN2(SUMI,SUMR)
SUMR = RSQRT*COS(THETA2)
SUMI = RSQRT*SIN(THETA2)
THETA2= 1./(SUMR**2 + SUMI**2)
SUMR = SUMR*THETA2
SUMI =-SUMI*THETA2
DO 35 J = L,K,2
JJ = J + 1
THETA2= Z(J)
Z(J ) = SUMR*Z(J) - SUMI*Z(JJ)
35 Z(JJ) = SUMI*THETA2 + SUMR*Z(JJ)
C
C -------------- SPECIAL PRINT --------------------------
C
IF (.NOT.QPR) GO TO 36
WRITE (NOUT,4424) (Z(J),J=L,K)
C
C CHECK NORMALITY
C
SUMR = 0.
SUMI = 0.
DO 1008 J = L,K,2
JJ = J + 1
SUMR = SUMR + Z(J)**2 - Z(JJ)**2
1008 SUMI = SUMI + 2.*Z(J)*Z(JJ)
WRITE (NOUT,7770) SUMR,SUMI
C -------------------------------------------------------
C
36 CONTINUE
C
C COMPUTE THEORETICAL EIGENVALUE ERRORS
C
IF (QPR) WRITE (NOUT,650) DMP1
IHL1 = IHL - 1
DO 50 I = 1,NROW
K = IL + 2*(I-1)
DENOM = SQRT(Z(K)**2 + Z(K+1)**2)
IF (DENOM .GT. 0.) GO TO 40
WRITE (NOUT,550) UIM,I
DENOM = 1.E-10
40 DENOM = 1./DENOM
K = IA + NROW2*I - 2
KK = K + 1
J = IHL1 + I
Z(J) = DENOM*SQRT((DMP1(1)*Z(K) - DMP1(2)*Z(KK))**2
1 + (DMP1(1)*Z(KK) + DMP1(2)*Z(K))**2)
IF (QPR) WRITE (NOUT,660) I,Z(J),Z(K),Z(KK),DENOM
50 CONTINUE
C
C RECOVER PHYSICAL EIGENVALUES
C
RMS = 0.
IF (NO B) GO TO 54
ALAM(1) = LAMBDA(1)
ALAM(2) = LAMBDA(2)
GO TO 55
54 ALAM(1) = LAMBDA(1)**2 - LAMBDA(2)**2
ALAM(2) = 2.D0*LAMBDA(1)*LAMBDA(2)
55 DO 70 I = 1,NROW
K = IL + 2*(I-1)
KK = K + 1
DENOM = Z(K)**2 + Z(KK)**2
IF (DENOM .EQ. 0.) DENOM = 1.E-20
DENOM = 1./DENOM
Z( K) = DENOM*Z( K) + ALAM(1)
Z(KK) =-DENOM*Z(KK) + ALAM(2)
IF (NO B) GO TO 60
GO TO 70
C
C DAMPING MATRIX ABSENT
C
60 RSQRT = SQRT(SQRT(Z(K)**2 + Z(KK)**2))
THETA2 = .5*ATAN2(Z(KK),Z(K))
Z( K) = RSQRT*COS(THETA2)
Z(KK) = RSQRT*SIN(THETA2)
IF (Z(KK) .GE. 0.) GO TO 70
Z( K) =-Z( K)
Z(KK) =-Z(KK)
C
C COMPUTE RMS FOR RIGID-BODY ERROR TEST
C
70 RMS = RMS + SQRT((Z(K)**2-Z(KK)**2)**2 + 4.*(Z(K)*Z(KK))**2)
RMS = SQRT(RMS)/FLOAT(NROW)
IF (QPR) WRITE (NOUT,800) RMS
J = IH - 1
IF (QPR) WRITE (NOUT,4420) (Z(I),I=IL,J)
C
C PERFORM RIGID-BODY ERROR TEST
C
IF (RMS .LT. 1.E-20) RMS = 1.E-20
RMS = 1./RMS
DO 80 I = 1,NROW
K = IL + 2*(I-1)
J = IHL1 + I
IF (RMS*SQRT(Z(K)**2+Z(K+1)**2) .LE. TENMTT) Z(J) = 0.
80 CONTINUE
C
C COMPUTE DISTANCES OF EIGENVALUES TO CENTER OF NEIGHBORHOOD
C
ALAM(1) = LAMBDA(1)
ALAM(2) = LAMBDA(2)
JJ = INTQ - 1
KK = IH - 1
LL = INTH - 1
DO 90 I = 1,NROW
J = JJ + I
K = IL + 2*(I-1)
Z(J) = SQRT((ALAM(1) - Z(K))**2 + (ALAM(2)-Z(K+1))**2)
C
C LOAD ORDER OF EXTRACTION
C
K = KK + I
IZ(K) = I
C
C LOAD STATUS OF EACH SOLUTION
C
K = LL + I
LZ(K) = .FALSE.
J = IHL1 + I
IF (Z(J) .LT. SNGL(EPS)) LZ(K) = .TRUE.
90 CONTINUE
C
C SORT EIGENVALUES ACCORDING TO DISTANCE FROM CURRENT CENTER
C
IF (NROW .EQ. 1) GO TO 150
LL = NROW - 1
DO 140 I = 1,LL
K = JJ + I
I1 = KK + I
LLL= I + 1
DO 130 J = LLL,NROW
L = JJ + J
IF (Z(K) .LT. Z(L)) GO TO 130
UNIDUM = Z(L)
Z(L) = Z(K)
Z(K) = UNIDUM
I2 = KK + J
INIDUM = IZ(I1)
IZ(I1) = IZ(I2)
IZ(I2) = INIDUM
130 CONTINUE
140 CONTINUE
150 LLL = IL - 1
LL = INTH - 1
IF (IDIAG .EQ. 0) GO TO 170
C
C PRINT OUT FULL SUMMARY FOR CURRENT NEIGHBORHOOD
C
WRITE (NOUT,670) JREG,NOREG,ALAM
WRITE (NOUT,680)
WRITE (NOUT,690)
DO 160 I = 1,NROW
K = KK + I
IZZ = 2*IZ(K) - 1
J = JJ + I
L = LLL + IZZ
L1 = L + 1
I1 = IHL1+ IZ(K)
Z(I1) = 100.*Z(I1)
I2 = LL + IZ(K)
STATUS(1) = ACCEPT(1)
STATUS(2) = ACCEPT(2)
IF (LZ(I2)) GO TO 160
STATUS(1) = REJECT(1)
STATUS(2) = REJECT(2)
160 WRITE (NOUT,700) I,IZ(K),Z(J),Z(L),Z(L1),Z(I1),STATUS
C
C DECREMENT COUNTERS SO THAT ONLY ACCEPTABLE SOLUTIONS ARE RETAINED
C
170 MSAVE = NROW
DO 180 I = 1,MSAVE
I2 = LL + I
IF (LZ(I2)) GO TO 180
NROW = NROW - 1
NORTHO = NORTHO - 1
IF (NROW .EQ. 0) GO TO 450
180 CONTINUE
NFOUND = NZERO + NROW
IF (NROW .EQ. MSAVE) WRITE (NOUT,720) UIM,MSAVE
IF (IDIAG.EQ.0 .OR. NROW.EQ.MSAVE) GO TO 200
C
C PRINT OUT SUMMARY WITH REJECTED SOLUTIONS DELETED
C
WRITE (NOUT,670) JREG,NOREG,ALAM
WRITE (NOUT,730)
WRITE (NOUT,690)
M = 0
DO 190 I = 1,MSAVE
K = KK + I
I2 = LL + IZ(K)
IF (.NOT.LZ(I2)) GO TO 190
M = M + 1
IZZ= 2*IZ(K) - 1
J = JJ + I
L = LLL + IZZ
L1 = L + 1
I1 = IHL1+ IZ(K)
WRITE (NOUT,700) M,IZ(K),Z(J),Z(L),Z(L1),Z(I1),ACCEPT
190 CONTINUE
200 M = MSAVE - NROW
IF (M .GT. 0) WRITE (NOUT,740) UIM,NROW,M
C
C WRITE EIGENVALUES TO OUTPUT FILE
C
CALL GOPEN (ILAM(1),Z(IBUF1),WRT)
DO 210 I = 1,MSAVE
K = KK + I
I2 = LL + IZ(K)
IF (.NOT.LZ(I2)) GO TO 210
IZZ = 2*IZ(K) - 1
L = LLL + IZZ
LAM1(1) = DBLE(Z(L ))
LAM1(2) = DBLE(Z(L+1))
CALL WRITE (ILAM(1),LAM1(1),4,1)
210 CONTINUE
CALL CLOSE (ILAM(1),EOFNRW)
IF (JREG.LT.NOREG .AND. NFOUND.LT.NORD) GO TO 214
IF (NZERO .EQ. 0) GO TO 214
C
C IF THIS IS THE FINAL (BUT NOT THE FIRST) NEIGHBORHOOD, THEN
C RE-WRITE THE EIGENVECTOR FILE PERTAINING TO ALL PRIOR
C NEIGHBORHOODS (ELIMINATE LEFT-HAND VECTORS)
C
209 IF (IDIAG .NE. 0) WRITE (NOUT,810) NZERO,NORTHO
INIDUM = ISCR(10)
CALL OPEN (*455,ISCR(10),Z(IBUF2),WRTREW)
CALL CLOSE (ISCR(10),REW)
J = NORD2
IF (NO B) J = 2*J
INIDUM = IPHI(1)
CALL OPEN (*455,IPHI(1),Z(IBUF1),0)
DO 212 I = 1,NZERO
CALL READ (*460,*211,IPHI(1),Z(IV2),NORD8+10,0,N3)
GO TO 470
211 CALL GOPEN (ISCR(10),Z(IBUF2),WRT)
CALL WRITE (ISCR(10),Z(IV2),J,1)
212 CALL CLOSE (ISCR(10),NOREW)
CALL CLOSE (IPHI(1),NOREW)
CALL OPEN (*455,IPHI(1),Z(IBUF1),WRTREW)
CALL CLOSE (IPHI(1),REW)
INIDUM = ISCR(10)
CALL OPEN (*455,ISCR(10),Z(IBUF2),0)
DO 213 I = 1,NZERO
CALL READ (*460,*206,ISCR(10),Z(IV2),J+10,0,N3)
GO TO 470
206 CALL GOPEN (IPHI(1),Z(IBUF1),WRT)
CALL WRITE (IPHI(1),Z(IV2),J,1)
213 CALL CLOSE (IPHI(1),EOFNRW)
CALL CLOSE (ISCR(10),NOREW)
IF(NSWP(2) .LT. 0) GO TO 500
C
C RECOVER PHYSICAL EIGENVECTORS, PRINT, AND WRITE TO OUTPUT FILE
C
214 IPRC = IPREC + 2
II = 1
NN = NORD2
INCR = 1
IA1 = IA - 1
IF (QPR) WRITE (NOUT,750)
ISHFT = NORD2*IPREC
I1 = 0
C
C ENTER LOOP
C
DO 300 I = 1,MSAVE
K = KK + I
I2 = LL + IZ(K)
IF (.NOT. LZ(I2)) GO TO 300
CALL GOPEN (ISCR(7),Z(IBUF2),RDREW)
IF (NZERO .GT. 0) CALL SKPREC (ISCR(7),NZERO)
DO 215 J = 1,NORD8
M = IV1X + J
215 Z(M) = 0.
C
C SET POINTER TO ALLMAT OUTPUT VECTOR
C
IB = IA1 + 2*MSAVE*(IZ(K)-1)
C
C CYCLE THRU ALL ORTHOGONAL VECTORS
C
DO 225 J = 1,MSAVE
C
C NOTE.... Z(IV2) MAY BE LOADED DOUBLE-PRECISION....HIGHER DIGITS
C ARE NOT USED
C (HIGHER DIGITS MUST BE INCLUDED FOR THE D.P.MACHINES. G.C/UNISYS)
C
CALL UNPACK (*225,ISCR(7),Z(IV2))
KR = IB + 2*J - 1
KI = KR + 1
DO 220 MM = 1,NORD2,2
MR = IV2 + (MM-1)*IPREC
MI = MR + IPREC
JR = IV1X+ MM
JI = JR + 1
IF (.NOT.DPMACH) GO TO 216
MRD = (MR+1)/2
MID = MRD + 1
C
C RECOVER RIGHT-HAND PHYSICAL EIGENVECTOR
C
Z(JR) = Z(JR) + DZ(MRD)*Z(KR) - DZ(MID)*Z(KI)
Z(JI) = Z(JI) + DZ(MID)*Z(KR) + DZ(MRD)*Z(KI)
GO TO 217
216 Z(JR) = Z(JR) + Z(MR)*Z(KR) - Z(MI)*Z(KI)
Z(JI) = Z(JI) + Z(MI)*Z(KR) + Z(MR)*Z(KI)
217 MR = MR + ISHFT
MI = MR + IPREC
JR = JR + NORD4
JI = JR + 1
IF (.NOT.DPMACH) GO TO 218
MRD = (MR+1)/2
MID = MRD + 1
C
C RECOVER LEFT-HAND PHYSICAL EIGENVECTOR
C
Z(JR) = Z(JR) + DZ(MRD)*Z(KR) - DZ(MID)*Z(KI)
Z(JI) = Z(JI) + DZ(MID)*Z(KR) + DZ(MRD)*Z(KI)
GO TO 220
218 Z(JR) = Z(JR) + Z(MR)*Z(KR) - Z(MI)*Z(KI)
Z(JI) = Z(JI) + Z(MI)*Z(KR) + Z(MR)*Z(KI)
220 CONTINUE
225 CONTINUE
CALL CLOSE (ISCR(7),EOFNRW)
IF (.NOT.QPR) GO TO 230
I1 = I1 + 1
IZZ = 2*IZ(K) - 1
L = LLL + IZZ
MM = IV1X + NORD8
WRITE (NOUT,760) I1,IZ(K),Z(L),Z(L+1),(Z(J),J=IV1,MM)
WRITE (NOUT,770)
C
C EXPAND PHYSICAL EIGENVECTORS TO DOUBLE PRECISION FOR OUTPUT
C
230 LIM1 = IV1 + NORD2
LIM2 = LIM1 + NORD4
INIDUM = IV1X + NORD4
DO 240 J = 1,NORD2
KI = LIM1 - J
MI = 2*KI - IV1X
MR = MI - 1
MRD = (MR+1)/2
C
C EXPAND RIGHT-HAND VECTOR
C
Z(MI) = 0.
Z(MR) = Z(KI)
IF (DPMACH) DZ(MRD) = Z(KI)
KI = LIM2 - J
MI = 2*KI - INIDUM
MR = MI - 1
MRD = (MR+1)/2
C
C EXPAND LEFT -HAND VECTOR
C
Z(MI) = 0.
Z(MR) = Z(KI)
IF (DPMACH) DZ(MRD) = Z(KI)
240 CONTINUE
IF (.NOT.QPR) GO TO 250
WRITE (NOUT,770)
LIM1 = IV1X + NORD4
WRITE (NOUT,780) (Z(J),J=IV1,LIM1)
WRITE (NOUT,770)
LIM2 = LIM1 + NORD4
LIM1 = LIM1 + 1
WRITE (NOUT,780) (Z(J),J=LIM1,LIM2)
WRITE (NOUT,770)
C
C PERFORM SPECIAL NORMALIZATION OF VECTORS FOR OUTPUT
C
250 CALL CNORM1 (Z(IV1),IKMB(2))
IF (QPR) WRITE (NOUT,790)
INIDUM = INIDUM + 1
CALL CNORM1 (Z(INIDUM),IKMB(2))
IF (QPR) WRITE (NOUT,790)
CALL GOPEN (IPHI(1),Z(IBUF1),WRT)
IF (JREG.LT.NOREG .AND. NFOUND.LT.NORD) GO TO 260
J = NORD2
IF (NO B) J = 2*J
CALL WRITE (IPHI(1),Z(IV1),J,1)
CALL CLOSE (IPHI(1),EOFNRW)
GO TO 300
C
C MUST USE NORD8 TO WRITE FULL RIGHT AND LEFT EIGENVECTORS
C
260 CALL WRITE (IPHI(1),Z(IV1),NORD8,1)
CALL CLOSE (IPHI(1),NOREW)
300 CONTINUE
GO TO 500
420 WRITE (NOUT,530) NAME
GO TO 500
430 WRITE (NOUT,540) M,NAME
GO TO 500
440 WRITE (NOUT,580) UWM
IF(NZERO.GT.0 .AND. JREG.EQ.NOREG) NSWP(2) = -1
GO TO 500
450 WRITE (NOUT,710) UWM,MSAVE
GO TO 500
455 CALL MESAGE (-1,INIDUM,NAME)
460 CALL MESAGE (-2,INIDUM,NAME)
470 CALL MESAGE (-8,INIDUM,NAME)
500 RETURN
C
530 FORMAT (27H UNEXPECTED EOF ENCOUNTERED,2X,2A4)
540 FORMAT (22H UNEXPECTED WORD COUNT,I5,2X,2A4)
550 FORMAT (A29,' 3152', //5X,'SUBROUTINE ALLMAT OUTPUT EIGENVALUE',
1 I4,' IS NULL.',//)
560 FORMAT (A25,' 3153', //5X,'ATTEMPT TO NORMALIZE NULL VECTOR IN ',
1 'SUBROUTINE ',A4,A2,'. NO ACTION TAKEN.',//)
570 FORMAT (A25,' 3154', //5X,'SIZE OF REDUCED PROBLEM DECREMENTED ',
1 'ONCE (NOW',I6,') DUE TO NULL ERROR ELEMENT.',//)
580 FORMAT (A25,' 3155', //5X,'REDUCED PROBLEM HAS VANISHED. NO ',
1 'ROOTS FOUND.',//)
590 FORMAT (A25,' 3156', //5X,'SIZE OF REDUCED PROBLEM RESTORED TO',
1 I8,' BECAUSE NEXT ERROR ELEMENT WAS ALSO NULL.', /5X,
3 'ERROR ELEMENT SET = ',2E16.8,//)
600 FORMAT (1H0,//7H CFEER4,//)
610 FORMAT (1H ,I10,36H SINGLE PRECISION WORDS OF OPEN CORE,
1 29H NOT USED (SUBROUTINE CFEER4))
620 FORMAT (4H ROW,I5,2(4X,2E16.8))
630 FORMAT (4H ROW,I5,2(4X,2D16.8))
640 FORMAT (1H0,26HREDUCED TRIDIAGONAL MATRIX, /(1H ,6E16.8))
650 FORMAT (1H0,//30H THEORETICAL EIGENVALUE ERRORS,
1 20X,18HD-SUB-M-PLUS-ONE =,2E16.8,/)
660 FORMAT (1H ,I5,E16.8,20X,2E16.8,10X,E16.8)
670 FORMAT (1H1,27X,39H***** F E E R ***** (FAST EIGENVALUE,
1 27H EXTRACTION ROUTINE) *****, //4X,
2 24HSUMMARY FOR NEIGHBORHOOD,I3,3H OF,I3,1H.,10X,
3 21HNEIGHBORHOOD CENTER =,2E16.8,/)
680 FORMAT (4X,43HALL SOLUTIONS FOUND IN CURRENT NEIGHBORHOOD,
1 12H ARE LISTED.,/)
690 FORMAT (4X,7X,8HSOLUTION,7X,8HORDER OF,7X,8HDISTANCE,
1 10X,10HEIGENVALUE,14X,11HTHEORETICAL, /4X,
2 9X,6HNUMBER,5X,10HEXTRACTION,4X,11HFROM CENTER,
3 6X,4HREAL,9X,9HIMAGINARY,9X,5HERROR,12X,6HSTATUS,/)
700 FORMAT (4X,I12,I15,1P,E18.8,1P,3E15.7,7X,2A4)
710 FORMAT (A25,' 3163', //5X,'ALL',I6,' SOLUTIONS HAVE FAILED ',
1 'ACCURACY TEST. NO ROOTS FOUND.',//)
720 FORMAT (A29,' 3164',//5X,'ALL',I6,' SOLUTIONS ARE ACCEPTABLE.',//)
730 FORMAT (4X,37HREJECTED SOLUTIONS HAVE BEEN DELETED.,/)
740 FORMAT (A29,' 3165', //4X,I6,' SOLUTIONS HAVE BEEN ACCEPTED AND',
1 I4,' SOLUTIONS HAVE BEEN REJECTED.',//)
750 FORMAT (1H1,27X,39H***** F E E R ***** (FAST EIGENVALUE,
1 27H EXTRACTION ROUTINE) *****,//
2 42X,37HE I G E N V E C T O R S U M M A R Y,//1H ,
3 32(4H----),2H--)
760 FORMAT (1H ,8HSOLUTION,I4,8X,16HEXTRACTION ORDER,I4,
1 10X,10HEIGENVALUE,2X,1P,2E16.8, /(1H ,3(4X,1P,2E16.8)))
770 FORMAT (3H --,32(4H----))
780 FORMAT ((1H ,3(3X,2E16.8)))
790 FORMAT (1H ,12HAFTER CNORM1)
800 FORMAT (1H ,10X,5HRMS =,E16.8)
810 FORMAT (1H ,33HLEFT-HAND EIGENVECTORS ELIMINATED,20X,2I8)
END
|
LOCAL INCLUDE 'REFLG.INC'
C Local include for REFLG
INCLUDE 'INCS:ZPBUFSZ.INC'
INCLUDE 'INCS:PUVD.INC'
INTEGER MAXTIM, MAXSOU
PARAMETER (MAXTIM=100000)
PARAMETER (MAXSOU=300)
C
HOLLERITH XNAMEI(3), XCLAIN(2), XXSOUR(4,30), XCALC
REAL XSIN, XDISIN, XFLAG, CPARM(10), BADD(10)
COMMON /INPARM/ XNAMEI, XCLAIN, XSIN, XDISIN, XXSOUR, XCALC,
* XFLAG, CPARM, BADD
C
INTEGER SEQIN, DISKIN, JBUFSZ, OLDCNO, NUMAN(513), NANT, NSUB,
* NTIMES, NCHAN, NIF, IFGVER, OFGVER, NUMSU, NUMFQ, FGBUF1(512),
* FGBUF2(512), FGKOLS(MAXFGC), FGNUMV(MAXFGC), NFGSCR, NFGOUT,
* NOUTR, SUNUMS(MAXSOU), FCHAN, FTIME, FBL, FANTS, FEXT, OFGRNO,
* BLEXIS(MXBASE)
CHARACTER NAMEIN*12, CLAIN*6, SNMS(MAXSOU)*16, XSOUR(30)*16,
* CLCODE*4
REAL BUFF1(UVBFSS), TIMES(2,MAXTIM)
COMMON /BUFRS/ BUFF1, JBUFSZ
COMMON /REFLGC/ FGBUF1, FGBUF2, TIMES, NTIMES, SEQIN, DISKIN,
* OLDCNO, NUMAN, NANT, NSUB, NCHAN, NIF, IFGVER, OFGVER, NUMSU,
* NUMFQ, FGKOLS, FGNUMV, SUNUMS, NFGSCR, NFGOUT, NOUTR, FCHAN,
* FTIME, FBL, FANTS, FEXT, OFGRNO, BLEXIS
COMMON /CHRCOM/ NAMEIN, CLAIN, SNMS, XSOUR, CLCODE
LOCAL END
PROGRAM REFLG
C-----------------------------------------------------------------------
C! Compresses an FG table
C# UV Calibration EXT-appl
C-----------------------------------------------------------------------
C; Copyright (C) 2011-2012, 2015-2016, 2018
C; Associated Universities, Inc. Washington DC, USA.
C;
C; This program is free software; you can redistribute it and/or
C; modify it under the terms of the GNU General Public License as
C; published by the Free Software Foundation; either version 2 of
C; the License, or (at your option) any later version.
C;
C; This program is distributed in the hope that it will be useful,
C; but WITHOUT ANY WARRANTY; without even the implied warranty of
C; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
C; GNU General Public License for more details.
C;
C; You should have received a copy of the GNU General Public
C; License along with this program; if not, write to the Free
C; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
C; MA 02139, USA.
C;
C; Correspondence concerning AIPS should be addressed as follows:
C; Internet email: aipsmail@nrao.edu.
C; Postal address: AIPS Project Office
C; National Radio Astronomy Observatory
C; 520 Edgemont Road
C; Charlottesville, VA 22903-2475 USA
C-----------------------------------------------------------------------
C Compress an FG table
C Inputs:
C AIPS adverb Description.
C INNAME.....Input UV file name (name). Standard defaults.
C INCLASS....Input UV file name (class). Standard defaults.
C INSEQ......Input UV file name (seq. #). 0 => highest.
C INDISK.....Disk drive # of input UV file. 0 => any.
C CPARM......1=max. gap
C-----------------------------------------------------------------------
CHARACTER PRGM*6, PHNAME*48
INTEGER ISUB, IRET, IFLAG(2), NWORDS, NBL, ISU, IFQ, IIF, IERR,
* JSU
LONGINT PIFLAG
INCLUDE 'REFLG.INC'
INCLUDE 'INCS:DFIL.INC'
INCLUDE 'INCS:DMSG.INC'
INCLUDE 'INCS:DDCH.INC'
INCLUDE 'INCS:DHDR.INC'
INCLUDE 'INCS:DUVH.INC'
INCLUDE 'INCS:DHIS.INC'
INCLUDE 'INCS:DSEL.INC'
DATA PRGM /'REFLG '/
C-----------------------------------------------------------------------
C Get input parameters.
CALL REFLIN (PRGM, IRET)
IF (IRET.NE.0) GO TO 990
NBL = (NANT * (NANT+1)) / 2
C loop over subarrays, sources,
C FQs
DO 100 IFQ = 1,NUMFQ
DO 90 ISUB = 1,NSUB
DO 80 JSU = 1,NUMSU
ISU = SUNUMS(JSU)
C Get list of times
CALL REFLTI (JSU, ISUB, IFQ, IRET)
IF (IRET.NE.0) GO TO 980
IF (NTIMES.GT.0) THEN
NWORDS = (NCHAN * NBL * NTIMES - 1) / 1024 + 2
CALL ZMEMRY ('GET ', PRGM, NWORDS, IFLAG, PIFLAG,
* IRET)
IF (IRET.NE.0) THEN
MSGTXT = 'FAILED TO GET REQUIRED MEMORY'
CALL MSGWRT (8)
GO TO 980
END IF
C redo flags
DO 70 IIF = 1,NIF
CALL REFLFG (IIF, ISU, ISUB, IFQ, NCHAN, NBL,
* IFLAG(1+PIFLAG), IRET)
IF (IRET.NE.0) GO TO 980
70 CONTINUE
CALL ZMEMRY ('FREE', PRGM, NWORDS, IFLAG, PIFLAG,
* IRET)
IF (IRET.NE.0) THEN
MSGTXT = 'FAILED TO FREE DYNAMIC MEMORY'
CALL MSGWRT (8)
GO TO 980
END IF
END IF
80 CONTINUE
90 CONTINUE
100 CONTINUE
C summary
WRITE (MSGTXT,1100) NFGSCR, NOUTR
CALL MSGWRT (5)
NFGSCR = NFGSCR + NFGOUT
NFGOUT = NFGOUT + NOUTR
C try for more global
CALL REFLGL (IRET)
C HI file
CALL REFLHI
GO TO 985
C delete on failure
980 CALL ZPHFIL ('FG', DISKIN, OLDCNO, OFGVER, PHNAME, IERR)
CALL ZDESTR (DISKIN, PHNAME, IERR)
CALL DELEXT ('FG', DISKIN, OLDCNO, 'RDRD', BUFF1, FGBUF1, OFGVER,
* IERR)
C delete scratch
985 IIF = OFGVER + 1
CALL ZPHFIL ('FG', DISKIN, OLDCNO, IIF, PHNAME, IERR)
CALL ZDESTR (DISKIN, PHNAME, IERR)
CALL DELEXT ('FG', DISKIN, OLDCNO, 'RDRD', BUFF1, FGBUF1, IIF,
* IERR)
C Close down files, etc.
990 CALL DIE (IRET, BUFF1)
C
999 STOP
C-----------------------------------------------------------------------
1100 FORMAT ('T-F in baseline process of',I10,' FG records into',I10)
END
SUBROUTINE REFLIN (PRGN, JERR)
C-----------------------------------------------------------------------
C REFLIN gets input parameters for REFLG and finds input file.
C Inputs:
C PRGN C*6 Program name
C Output:
C JERR I Error code: 0 => ok
C 3 => Wrong sort order
C 4 => No source table
C 5 => catalog troubles
C 8 => can't start
C Commons: /INPARM/ all input adverbs in order given by INPUTS
C file
C /MAPHDR/ output file catalog header
C-----------------------------------------------------------------------
CHARACTER PRGN*6
INTEGER JERR
C
INCLUDE 'REFLG.INC'
CHARACTER STAT*4, UTYPE*2, VELTYP*8, VELDEF*8, SOUNAM*16,
* CALCOD*4, BNDCOD(MAXIF)*8
INTEGER NPARM, IROUND, IERR, ALUN, ISUB, I, BUFFER(512), NUMIF,
* RNOFQ, KOLS(MAXFQC), NUMV(MAXFQC), NREC, FQID, ISURNO, QUAL,
* SIDFQ(MAXIF), SUKOLS(MAXSUC), SUNUMV(MAXSUC), IDSOU, LUN, VER,
* LUNTMP, J, NS
DOUBLE PRECISION FREQO(MAXIF), BANDW, RAEPO, DECEPO, EPOCH, RAAPP,
* DECAPP, LSRVEL(MAXIF), LRESTF(MAXIF), PMRA, PMDEC, RAOBS,
* DECOBS
REAL TBWFQ(MAXIF), CHBWFQ(MAXIF), FLUX(4,MAXIF)
LOGICAL T, DESEL, FAIL
INCLUDE 'INCS:DFIL.INC'
INCLUDE 'INCS:DMSG.INC'
INCLUDE 'INCS:DHIS.INC'
INCLUDE 'INCS:DHDR.INC'
INCLUDE 'INCS:DDCH.INC'
INCLUDE 'INCS:DUVH.INC'
INCLUDE 'INCS:DCAT.INC'
DATA ALUN /29/
DATA T /.TRUE./
C-----------------------------------------------------------------------
C Init for AIPS, disks, ...
CALL ZDCHIN (T)
CALL VHDRIN
JBUFSZ = UVBFSS * 2
C Initialize /CFILES/
NFGSCR = 0
NCFILE = 0
JERR = 0
C Get input parameters.
NPARM = 148
CALL GTPARM (PRGN, NPARM, RQUICK, XNAMEI, BUFF1, IERR)
IF (IERR.NE.0) THEN
RQUICK = .TRUE.
JERR = 8
IF (IERR.EQ.1) GO TO 999
WRITE (MSGTXT,1000) IERR
CALL MSGWRT (8)
END IF
C Restart AIPS
IF (RQUICK) CALL RELPOP (JERR, BUFF1, IERR)
IF (JERR.NE.0) GO TO 999
JERR = 5
C Crunch input parameters.
SEQIN = IROUND (XSIN)
DISKIN = IROUND (XDISIN)
CALL H2CHR (12, 1, XNAMEI, NAMEIN)
CALL H2CHR (6, 1, XCLAIN, CLAIN)
DO 5 I = 1,10
IBAD(I) = IROUND(BADD(I))
5 CONTINUE
C Get CATBLK from old file.
OLDCNO = 1
UTYPE = 'UV'
CALL CATDIR ('SRCH', DISKIN, OLDCNO, NAMEIN, CLAIN, SEQIN, UTYPE,
* NLUSER, STAT, BUFF1, IERR)
IF (IERR.NE.0) THEN
WRITE (MSGTXT,1030) IERR, NAMEIN, CLAIN, SEQIN, DISKIN,
* NLUSER
GO TO 990
END IF
CALL CATIO ('READ', DISKIN, OLDCNO, CATBLK, 'REST', BUFF1, IERR)
IF (IERR.NE.0) THEN
WRITE (MSGTXT,1040) IERR
GO TO 990
END IF
NCFILE = NCFILE + 1
FVOL(NCFILE) = DISKIN
FCNO(NCFILE) = OLDCNO
FRW(NCFILE) = 0
C Get uv header info.
CALL UVPGET (JERR)
IF (JERR.NE.0) GO TO 999
C Check sort order
IF (ISORT(:1).NE.'T') THEN
JERR = 3
WRITE (MSGTXT,1050) ISORT
GO TO 990
END IF
C flag ver
CALL FNDEXT ('FG', CATBLK, I)
IFGVER = IROUND (XFLAG)
IF ((IFGVER.LE.0) .OR. (IFGVER.GT.I)) IFGVER = I
OFGVER = I + 1
IF (I.LE.0) THEN
MSGTXT = 'NO FG TABLE TO COMPRESS'
JERR = 3
GO TO 990
END IF
NCHAN = CATBLK(KINAX+JLOCF)
NIF = 1
IF (JLOCIF.GE.0) NIF = CATBLK(KINAX+JLOCIF)
C Get number of antennas
CALL GETNAN (DISKIN, OLDCNO, CATBLK, ALUN, BUFF1, NUMAN, JERR)
IF (JERR.NE.0) THEN
WRITE (MSGTXT,1070) JERR
CALL MSGWRT (7)
ELSE
NSUB = NUMAN(1)
NANT = 0
DO 100 ISUB = 1,NSUB
NANT = MAX (NANT, NUMAN(ISUB+1))
100 CONTINUE
END IF
C source list
NS = 0
DESEL = .FALSE.
DO 110 I = 1,30
CALL H2CHR (16, 1, XXSOUR(1,I), SOUNAM)
IF (SOUNAM.NE.' ') THEN
NS = NS + 1
IF (SOUNAM(1:1).EQ.'-') THEN
DESEL = .TRUE.
XSOUR(NS) = SOUNAM(2:)
ELSE
XSOUR(NS) = SOUNAM
END IF
END IF
110 CONTINUE
CALL H2CHR (4, 1, XCALC, CLCODE)
C get max source number
LUN = LUNTMP (1)
CALL FNDEXT ('SU', CATBLK, I)
IF (I.LE.0) THEN
NUMSU = 1
SUNUMS(1) = 1
SNMS(1) = ' '
ELSE
NUMSU = 0
VER = 1
CALL SOUINI ('READ', BUFFER, DISKIN, OLDCNO, VER, CATBLK, LUN,
* NUMIF, VELTYP, VELDEF, FQID, ISURNO, SUKOLS, SUNUMV, JERR)
IF (JERR.NE.0) THEN
WRITE (MSGTXT,1100) JERR, 'OPENING SU TABLE'
GO TO 990
END IF
NREC = BUFFER(5)
DO 130 I = 1,NREC
CALL TABSOU ('READ', BUFFER, ISURNO, SUKOLS, SUNUMV, IDSOU,
* SOUNAM, QUAL, CALCOD, FLUX, FREQO, BANDW, RAEPO, DECEPO,
* EPOCH, RAAPP, DECAPP, RAOBS, DECOBS, LSRVEL, LRESTF,
* PMRA, PMDEC, JERR)
IF (JERR.NE.0) THEN
WRITE (MSGTXT,1100) JERR, 'READING SU TABLE'
GO TO 990
END IF
FAIL = .FALSE.
IF ((NS.GT.0) .OR. (CLCODE.NE.' ')) THEN
IF (CLCODE.EQ.'*') THEN
FAIL = CALCOD.EQ.' '
ELSE IF (CLCODE.EQ.'-CAL') THEN
FAIL = CALCOD.NE.' '
ELSE IF (CLCODE.NE.' ') THEN
FAIL = CLCODE.NE.CALCOD
END IF
IF ((.NOT.FAIL) .AND. (NS.GT.0)) THEN
DO 120 J = 1,NS
IF (XSOUR(J).EQ.SOUNAM) THEN
FAIL = DESEL
GO TO 125
END IF
120 CONTINUE
FAIL = .NOT.DESEL
END IF
END IF
125 IF (.NOT.FAIL) THEN
NUMSU = NUMSU + 1
SUNUMS(NUMSU) = IDSOU
SNMS(NUMSU) = SOUNAM
END IF
130 CONTINUE
CALL TABSOU ('CLOS', BUFFER, ISURNO, SUKOLS, SUNUMV, IDSOU,
* SOUNAM, QUAL, CALCOD, FLUX, FREQO, BANDW, RAEPO, DECEPO,
* EPOCH, RAAPP, DECAPP, RAOBS, DECOBS, LSRVEL, LRESTF, PMRA,
* PMDEC, JERR)
IF (JERR.NE.0) THEN
WRITE (MSGTXT,1100) JERR, 'CLOSING SU TABLE'
GO TO 990
END IF
END IF
C getn max FQ number
CALL FNDEXT ('FQ', CATBLK, I)
IF (I.LE.0) THEN
NUMFQ = 1
ELSE
NUMFQ = 0
VER = 1
CALL FQINI ('READ', BUFFER, DISKIN, OLDCNO, VER, CATBLK, LUN,
* RNOFQ, KOLS, NUMV, NUMIF, JERR)
IF (JERR.NE.0) THEN
WRITE (MSGTXT,1100) JERR, 'OPENING FQ TABLE'
GO TO 990
END IF
NREC = BUFFER(5)
RNOFQ = 1
DO 140 I = 1,NREC
CALL TABFQ ('READ', BUFFER, RNOFQ, KOLS, NUMV, NUMIF,
* FQID, FREQO, CHBWFQ, TBWFQ, SIDFQ, BNDCOD, JERR)
IF (JERR.NE.0) THEN
WRITE (MSGTXT,1100) JERR, 'READING FQ TABLE'
GO TO 990
END IF
NUMFQ = MAX (NUMFQ, FQID)
140 CONTINUE
CALL TABFQ ('CLOS', BUFFER, RNOFQ, KOLS, NUMV, NUMIF,
* FQID, FREQO, CHBWFQ, TBWFQ, SIDFQ, BNDCOD, JERR)
IF (JERR.NE.0) THEN
WRITE (MSGTXT,1100) JERR, 'CLOSING FQ TABLE'
GO TO 990
END IF
END IF
C prepare FG files for work
CALL FGPREP (BUFFER, JERR)
C counters
FCHAN = 0
FTIME = 0
FBL = 0
FANTS = 0
FEXT = 0
CALL FILL (MXBASE, 0, BLEXIS)
GO TO 999
C
990 CALL MSGWRT (8)
C
999 RETURN
C-----------------------------------------------------------------------
1000 FORMAT ('REFLIN: ERROR',I3,' OBTAINING INPUT PARAMETERS')
1030 FORMAT ('ERROR',I3,' FINDING ',A12,'.',A6,'.',I4,' DISK=',
* I3,' USID=',I5)
1040 FORMAT ('ERROR',I3,' COPYING CATBLK ')
1050 FORMAT ('WRONG SORT ORDER(',A2,'), USE UVSRT TO SORT TO ''TB''')
1070 FORMAT ('REFLIN: ERROR ',I3,' DETERMINING NUMBER OF ANTENNAS')
1100 FORMAT ('REFLIN ERROR:',I5,' ON ',A)
END
SUBROUTINE FGPREP (BUFFER, IRET)
C-----------------------------------------------------------------------
C FGPREP separates the flags into two FG files - the channel and IF
C dependent ones (OFGVER+1) and the rest (OFGVER)
C Outputs:
C BUFFER I(512) Input FG work buffer
C IRET I Error code
C-----------------------------------------------------------------------
INTEGER BUFFER(512), IRET
C
INCLUDE 'REFLG.INC'
INTEGER LUN1, LUN2, LUN3, LUNTMP, VER, NREC, IREC, IFGRNO, I,
* FGRNO1, FGRNO2, SOURID, SUBA, FREQID, ANTS(2), IFS(2), NST,
* CHANS(2), ISU
REAL TIMER(2)
LOGICAL PFLAGS(4), COPY
CHARACTER REASON*24
INCLUDE 'INCS:DMSG.INC'
INCLUDE 'INCS:DDCH.INC'
INCLUDE 'INCS:DCAT.INC'
INCLUDE 'INCS:DHDR.INC'
INCLUDE 'INCS:DUVH.INC'
C-----------------------------------------------------------------------
NST = CATBLK(KINAX+JLOCS)
C open input FG
LUN1 = LUNTMP (1)
CALL FLGINI ('READ', BUFFER, DISKIN, OLDCNO, IFGVER, CATBLK, LUN1,
* IFGRNO, FGKOLS, FGNUMV, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'OPENING INPUT FG TABLE'
GO TO 990
END IF
C open output FG
LUN2 = LUNTMP (1)
CALL FLGINI ('WRIT', FGBUF1, DISKIN, OLDCNO, OFGVER, CATBLK, LUN2,
* FGRNO1, FGKOLS, FGNUMV, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'OPENING OUTPUT FG TABLE'
GO TO 990
END IF
C open scratch FG
LUN3 = LUNTMP (1)
VER = OFGVER + 1
CALL FLGINI ('WRIT', FGBUF2, DISKIN, OLDCNO, VER, CATBLK, LUN3,
* FGRNO2, FGKOLS, FGNUMV, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'OPENING SCRATCH FG TABLE'
GO TO 990
END IF
NREC = BUFFER(5)
NFGSCR = 0
NFGOUT = 0
C read loop
DO 100 IREC = 1,NREC
CALL TABFLG ('READ', BUFFER, IFGRNO, FGKOLS, FGNUMV, SOURID,
* SUBA, FREQID, ANTS, TIMER, IFS, CHANS, PFLAGS, REASON,
* IRET)
IF (IRET.GT.0) THEN
WRITE (MSGTXT,1000) IRET, 'READING INPUT FG TABLE'
GO TO 990
ELSE IF (IRET.EQ.0) THEN
COPY = ((ANTS(1).GT.0) .AND. (ANTS(2).GT.0) .AND.
* (IFS(1).GT.0) .AND. (IFS(2).GT.0) .AND.
* (CHANS(1).GT.0) .AND. (CHANS(2).GT.0) .AND.
* ((TIMER(1).GT.0.0) .OR. (TIMER(2).LT.1000.)))
C flagging all?
DO 10 I = 1,NST
COPY = (COPY) .AND. (PFLAGS(I))
10 CONTINUE
C check source
IF ((NUMSU.GT.0) .AND. (SOURID.GT.0) .AND. (COPY)) THEN
DO 20 ISU = 1,NUMSU
IF (SOURID.EQ.SUNUMS(ISU)) GO TO 30
20 CONTINUE
COPY = .FALSE.
END IF
C for scratch
30 IF (COPY) THEN
CALL TABFLG ('WRIT', FGBUF2, FGRNO2, FGKOLS, FGNUMV,
* SOURID, SUBA, FREQID, ANTS, TIMER, IFS, CHANS, PFLAGS,
* REASON, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'WRITING SCRATCH FG TABLE'
GO TO 990
END IF
NFGSCR = NFGSCR + 1
ELSE
CALL TABFLG ('WRIT', FGBUF1, FGRNO1, FGKOLS, FGNUMV,
* SOURID, SUBA, FREQID, ANTS, TIMER, IFS, CHANS, PFLAGS,
* REASON, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'WRITING SCRATCH FG TABLE'
GO TO 990
END IF
NFGOUT = NFGOUT + 1
END IF
END IF
100 CONTINUE
CALL TABFLG ('CLOS', BUFFER, IFGRNO, FGKOLS, FGNUMV, SOURID, SUBA,
* FREQID, ANTS, TIMER, IFS, CHANS, PFLAGS, REASON, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'READING INPUT FG TABLE'
GO TO 990
END IF
CALL TABFLG ('CLOS', FGBUF2, FGRNO2, FGKOLS, FGNUMV, SOURID, SUBA,
* FREQID, ANTS, TIMER, IFS, CHANS, PFLAGS, REASON, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'WRITING SCRATCH FG TABLE'
GO TO 990
END IF
CALL TABFLG ('CLOS', FGBUF1, FGRNO1, FGKOLS, FGNUMV, SOURID, SUBA,
* FREQID, ANTS, TIMER, IFS, CHANS, PFLAGS, REASON, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'WRITING SCRATCH FG TABLE'
GO TO 990
END IF
WRITE (MSGTXT,1100) NFGOUT, 'output flag table'
CALL MSGWRT (4)
WRITE (MSGTXT,1100) NFGSCR, 'temp FG table for processing'
CALL MSGWRT (4)
IF (NFGSCR.EQ.0) THEN
MSGTXT = 'No flags in scratch: skip reading sources'
CALL MSGWRT (4)
NUMSU = 0
END IF
NOUTR = 0
GO TO 999
C
990 CALL MSGWRT (8)
C
999 RETURN
C-----------------------------------------------------------------------
1000 FORMAT ('FGPREP ERROR:',I4,' ON ',A)
1100 FORMAT ('FGPREP: wrote',I10,' records to ',A)
END
SUBROUTINE REFLTI (ISU, ISUBA, IFQ, IRET)
C-----------------------------------------------------------------------
C REFLTI finds the list of times
C Input:
C Output: IRET I Return code, 0 => OK, otherwise abort.
C-----------------------------------------------------------------------
INTEGER ISU, ISUBA, IFQ, IRET
C
INCLUDE 'INCS:PUVD.INC'
INTEGER I, IA1, IA2, KBASE, NBL, ISDAT(MXBASE), JBL, CATSAV(256)
LOGICAL GETNEW
REAL CURTIM, TLIMIT, TINT, TB, RPARM(20)
INCLUDE 'REFLG.INC'
INCLUDE 'INCS:DMSG.INC'
INCLUDE 'INCS:DUVH.INC'
INCLUDE 'INCS:DHDR.INC'
INCLUDE 'INCS:DFIL.INC'
INCLUDE 'INCS:DDCH.INC'
INCLUDE 'INCS:DSEL.INC'
C-----------------------------------------------------------------------
C init DSEL parms
CALL SELINI
FGVER = -1
SUBARR = ISUBA
FRQSEL = IFQ
SOURCS(1) = SNMS(ISU)
UNAME = NAMEIN
UCLAS = CLAIN
UDISK = DISKIN
USEQ = SEQIN
CALL COPY (256, CATBLK, CATSAV)
C rflag parameters
IF (CPARM(1).LE.0.0) CPARM(1) = 10.
TLIMIT = 2.01 * CPARM(1)
TLIMIT = TLIMIT / (24. * 3600.)
TINT = CPARM(1) / (24. * 3600.)
TB = -1000.
NBL = (NANT * (NANT+1)) / 2
CALL FILL (NBL, 0, ISDAT)
NTIMES = 0
C init I/O
CALL UVGET ('INIT', RPARM, BUFF1, IRET)
IF (IRET.NE.0) THEN
IF (IRET.GT.0) THEN
WRITE (MSGTXT,1000) IRET, 'INIT READ ON ' // SOURCS(1)
GO TO 990
END IF
IRET = 0
GO TO 980
END IF
C Loop
C Read vis. record.
100 CALL UVGET ('READ', RPARM, BUFF1, IRET)
IF (IRET.GT.0) THEN
WRITE (MSGTXT,1000) IRET, 'READ VIS FOR ' // SOURCS(1)
GO TO 990
ELSE IF (IRET.EQ.0) THEN
CURTIM = RPARM(1+ILOCT)
IF (ILOCB.GE.0) THEN
KBASE = RPARM(1+ILOCB) + 0.1
IA1 = KBASE / 256
IA2 = KBASE - IA1 * 256
ELSE
IA1 = RPARM(1+ILOCA1) + 0.1
IA2 = RPARM(1+ILOCA2) + 0.1
END IF
JBL = NANT * (IA1-1) - ((IA1*(IA1-1))/2) + IA2
BLEXIS(JBL) = 1
C usable in this interval?
IF (ABS(CURTIM-TB).LT.TINT) THEN
GETNEW = ISDAT(JBL).GT.0
ISDAT(JBL) = 1
C definitely need new
ELSE
GETNEW = .TRUE.
END IF
IF (GETNEW) THEN
NTIMES = NTIMES + 1
TIMES(1,NTIMES) = CURTIM
TIMES(2,NTIMES) = CURTIM
TB = TIMES(1,NTIMES)
CALL FILL (NBL, 0, ISDAT)
ELSE
TIMES(1,NTIMES) = MIN (CURTIM, TIMES(1,NTIMES))
TIMES(2,NTIMES) = MAX (CURTIM, TIMES(2,NTIMES))
TB = TIMES(1,NTIMES)
END IF
GO TO 100
ELSE
IRET = 0
END IF
C Close files
980 CALL UVGET ('CLOS', RPARM, BUFF1, I)
CALL COPY (256, CATSAV, CATBLK)
GO TO 999
C Error
990 CALL MSGWRT (8)
C
999 RETURN
C-----------------------------------------------------------------------
1000 FORMAT ('REFLTI: ERROR',I3,' ON ',A)
END
SUBROUTINE REFLFG (IIF, ISU, ISUB, IFQ, NC, NBL, IFLAG, IRET)
C-----------------------------------------------------------------------
C Does the heavy lifting for REFLG
C Inputs:
C IIF I IF number this pass
C ISU I Source number
C ISUB I Subarray number
C IFQ I Frequency ID
C NC I Number channels
C NBL I Number baselines
C Output:
C IFLAG I(*) Work memory (NC,NBL,number of times)
C IRET I Error code
C-----------------------------------------------------------------------
INTEGER IIF, ISU, ISUB, IFQ, NC, NBL, IFLAG(NC,NBL,*), IRET
C
INCLUDE 'REFLG.INC'
INTEGER LUN, LUNTMP, VER, NREC, IREC, IFGRNO, SOURID, SUBA,
* FREQID, ANTS(2), IFS(2), CHANS(2), NFGIN, NFGOU, IFLAGS, ITB,
* ITE, IT0, IA1, IA2, ZOR, ZAND, IC, IT, IBL, MM, J, I, JC, JT,
* DATE(3), TIME(3), NN, NODD, FFCHAN, FFTIME, FFBL, IROUND,
* MASK, FFANTS, NEXT, NX, JXX, FFEXT
REAL TIMER(2), FRACT, TEPS
LOGICAL PFLAGS(4), INONE
CHARACTER REASON*24, ATIME*8, ADATE*12
INCLUDE 'INCS:DMSG.INC'
INCLUDE 'INCS:DCAT.INC'
C-----------------------------------------------------------------------
NFGIN = 0
NFGOU = 0
IC = NC * NBL * NTIMES
CALL FILL (IC, 0, IFLAG)
TEPS = 0.1 / (24.0 * 3600.0)
C open scratch FG
VER = OFGVER + 1
LUN = LUNTMP (1)
CALL FLGINI ('READ', FGBUF1, DISKIN, OLDCNO, VER, CATBLK, LUN,
* IFGRNO, FGKOLS, FGNUMV, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'OPENING SCRATCH FG TABLE'
GO TO 990
END IF
NREC = FGBUF1(5)
IT0 = 1
DO 50 IREC = 1,NREC
CALL TABFLG ('READ', FGBUF1, IFGRNO, FGKOLS, FGNUMV, SOURID,
* SUBA, FREQID, ANTS, TIMER, IFS, CHANS, PFLAGS, REASON,
* IRET)
IF (IRET.GT.0) THEN
WRITE (MSGTXT,1000) IRET, 'READING SCRATCH FG TABLE'
GO TO 990
ELSE IF (IRET.EQ.0) THEN
C applies to this data subset
IF ((IFS(1).LE.IIF) .AND. (IFS(2).GE.IIF) .AND.
* ((SUBA.LE.0) .OR. (SUBA.EQ.ISUB)) .AND.
* ((FREQID.LE.0) .OR. (FREQID.EQ.IFQ)) .AND.
* ((SOURID.LE.0) .OR. (SOURID.EQ.ISU))) THEN
NFGIN = NFGIN + 1
IFLAGS = 0
IF (PFLAGS(1)) IFLAGS = IFLAGS + 1
IF (PFLAGS(2)) IFLAGS = IFLAGS + 2
IF (PFLAGS(3)) IFLAGS = IFLAGS + 4
IF (PFLAGS(4)) IFLAGS = IFLAGS + 8
C find start time
IT0 = 1
DO 10 IT = IT0,NTIMES
IF (TIMER(1).GT.TIMES(2,IT)) THEN
IT0 = IT0 + 1
ELSE
ITB = IT0
GO TO 15
END IF
10 CONTINUE
C done
GO TO 60
C find end time
15 DO 20 IT = ITB,NTIMES
IF (TIMER(2).LT.TIMES(1,IT)) THEN
ITE = IT-1
GO TO 25
END IF
20 CONTINUE
ITE = NTIMES
C mark array
25 IA1 = MIN (ANTS(1), ANTS(2))
IA2 = MAX (ANTS(1), ANTS(2))
IBL = NANT * (IA1-1) - ((IA1*(IA1-1))/2) + IA2
DO 40 IT = ITB,ITE
DO 30 IC = CHANS(1),CHANS(2)
IFLAG(IC,IBL,IT) = ZOR (IFLAG(IC,IBL,IT), IFLAGS)
30 CONTINUE
40 CONTINUE
END IF
END IF
50 CONTINUE
60 CALL TABFLG ('CLOS', FGBUF1, IFGRNO, FGKOLS, FGNUMV, SOURID,
* SUBA,FREQID, ANTS, TIMER, IFS, CHANS, PFLAGS, REASON, IRET)
IF (IRET.GT.0) THEN
WRITE (MSGTXT,1000) IRET, 'CLOSING SCRATCH FG TABLE'
GO TO 990
END IF
WRITE (MSGTXT,1050) NFGIN, IIF, ISU, ISUB, IFQ
CALL MSGWRT (2)
MM = 0
DO 75 IT = 1,NTIMES
DO 70 IBL = 1,NBL
DO 65 IC = 1,NC
IF (IFLAG(IC,IBL,IT).GT.0) MM = MM + 1
65 CONTINUE
70 CONTINUE
75 CONTINUE
WRITE (MSGTXT,1075) MM
CALL MSGWRT (2)
C set reason for this call
CALL ZDATE (DATE)
CALL ZTIME (TIME)
CALL TIMDAT (TIME, DATE, ATIME, ADATE)
REASON = TSKNAM // ADATE // ATIME(:5)
C channels extend
NEXT = CPARM(2) + 0.5
IF (NEXT.GT.0) THEN
FFEXT = 0
DO 150 IT = 1,NTIMES
DO 140 IBL = 1,NBL
C extend at beginning?
IF (IFLAG(1,IBL,IT).EQ.0) THEN
DO 110 NX = 1,NEXT
IF (IFLAG(1+NX,IBL,IT).GT.0) THEN
CALL FILL (NX, 15, IFLAG(1,IBL,IT))
FFEXT = FFEXT + NX
GO TO 115
END IF
110 CONTINUE
END IF
C look through channels
115 INONE = .FALSE.
DO 130 IC = 1,NC
C extend
IF ((INONE) .AND. (IFLAG(IC,IBL,IT).EQ.0)) THEN
JXX = MIN (NC-IC, NEXT)
DO 120 NX = 1,JXX
IF (IFLAG(IC+NX,IBL,IT).GT.0) THEN
CALL FILL (NX, 15, IFLAG(IC,IBL,IT))
FFEXT = FFEXT + NX
GO TO 125
END IF
120 CONTINUE
IF (JXX.LT.NEXT) THEN
CALL FILL (JXX+1, 15, IFLAG(IC,IBL,IT))
FFEXT = FFEXT + JXX + 1
END IF
END IF
C mark if in one
125 IF (IFLAG(IC,IBL,IT).GT.0) THEN
INONE = .TRUE.
ELSE IF (IFLAG(IC,IBL,IT).EQ.0) THEN
INONE = .FALSE.
END IF
130 CONTINUE
140 CONTINUE
150 CONTINUE
IF (FFEXT.GT.0) THEN
WRITE (MSGTXT,1150) FFEXT
CALL MSGWRT (4)
FEXT = FEXT + FFEXT
END IF
END IF
C channels excess
FFCHAN = 0
IF ((CPARM(3).GT.0.0) .AND. (CPARM(3).LT.1.0)) THEN
DO 240 IT = 1,NTIMES
DO 230 IBL = 1,NBL
FRACT = 0.0
DO 210 IC = 1,NC
IF (IFLAG(IC,IBL,IT).NE.0) FRACT = FRACT + 1.0
210 CONTINUE
FRACT = FRACT / NC
IF ((FRACT.GT.CPARM(3)) .AND. (FRACT.LT.1.0)) THEN
FFCHAN = FFCHAN + 1
DO 220 IC = 1,NC
IF (IFLAG(IC,IBL,IT).EQ.0) IFLAG(IC,IBL,IT) = 15
220 CONTINUE
END IF
230 CONTINUE
240 CONTINUE
END IF
IF (FFCHAN.GT.0) THEN
WRITE (MSGTXT,1240) FFCHAN
CALL MSGWRT (4)
FCHAN = FCHAN + FFCHAN
END IF
C times excess
FFTIME = 0
IF ((CPARM(4).GT.0.0) .AND. (CPARM(4).LT.1.0)) THEN
DO 290 IC = 1,NC
DO 280 IBL = 1,NBL
FRACT = 0.0
DO 260 IT = 1,NTIMES
IF (IFLAG(IC,IBL,IT).NE.0) FRACT = FRACT + 1.0
260 CONTINUE
FRACT = FRACT / NTIMES
IF ((FRACT.GT.CPARM(4)) .AND. (FRACT.LT.1.0)) THEN
FFTIME = FFTIME + 1
DO 270 IT = 1,NTIMES
IF (IFLAG(IC,IBL,IT).EQ.0) IFLAG(IC,IBL,IT) = 15
270 CONTINUE
END IF
280 CONTINUE
290 CONTINUE
END IF
IF (FFTIME.GT.0) THEN
WRITE (MSGTXT,1290) FFTIME
CALL MSGWRT (4)
FTIME = FTIME + FFTIME
END IF
C baselines excess
FFBL = 0
IF ((CPARM(5).GT.0.0) .AND. (CPARM(5).LT.1.0)) THEN
DO 340 IT = 1,NTIMES
DO 330 IC = 1,NC
FRACT = 0.0
DO 310 IBL = 1,NBL
IF (IFLAG(IC,IBL,IT).NE.0) FRACT = FRACT + 1.0
310 CONTINUE
FRACT = FRACT / NBL
IF ((FRACT.GT.CPARM(5)) .AND. (FRACT.LT.1.0)) THEN
FFBL = FFBL + 1
DO 320 IBL = 1,NBL
IF (IFLAG(IC,IBL,IT).EQ.0) IFLAG(IC,IBL,IT) = 15
320 CONTINUE
END IF
330 CONTINUE
340 CONTINUE
END IF
IF (FFBL.GT.0) THEN
WRITE (MSGTXT,1340) FFBL
CALL MSGWRT (4)
FBL = FBL + FFBL
END IF
C antennas excess
FFANTS = 0
IF ((CPARM(6).GT.0.0) .AND. (CPARM(6).LT.1.0)) THEN
DO 450 IT = 1,NTIMES
DO 440 IC = 1,NC
DO 430 IA1 = 1,NANT
FRACT = 0.0
DO 410 IA2 = 1,NANT
IF (IA2.LT.IA1) THEN
IBL = NANT * (IA2-1) - ((IA2*(IA2-1))/2) + IA1
ELSE
IBL = NANT * (IA1-1) - ((IA1*(IA1-1))/2) + IA2
END IF
IF (IFLAG(IC,IBL,IT).NE.0) FRACT = FRACT + 1.0
410 CONTINUE
FRACT = FRACT / NANT
IF ((FRACT.GT.CPARM(6)) .AND. (FRACT.LT.1.0)) THEN
FFANTS = FFANTS + 1
DO 420 IA2 = 1,NANT
IF (IA2.LT.IA1) THEN
IBL = NANT * (IA2-1) - ((IA2*(IA2-1))/2) +
* IA1
ELSE
IBL = NANT * (IA1-1) - ((IA1*(IA1-1))/2) +
* IA2
END IF
IF (IFLAG(IC,IBL,IT).EQ.0) IFLAG(IC,IBL,IT) = 15
420 CONTINUE
END IF
430 CONTINUE
440 CONTINUE
450 CONTINUE
END IF
IF (FFANTS.GT.0) THEN
WRITE (MSGTXT,1450) FFANTS
CALL MSGWRT (4)
FANTS = FANTS + FFANTS
END IF
C flag more polarizations if some
MASK = IROUND (CPARM(7))
IF (MASK.EQ.1) THEN
MASK = 12
ELSE IF (MASK.GE.2) THEN
MASK = 15
ELSE
MASK = 0
END IF
IF (MASK.GT.0) THEN
DO 530 IT = 1,NTIMES
DO 520 IBL = 1,NBL
DO 510 IC = 1,NC
IF (IFLAG(IC,IBL,IT).GT.0) IFLAG(IC,IBL,IT) =
* ZOR (IFLAG(IC,IBL,IT), MASK)
510 CONTINUE
520 CONTINUE
530 CONTINUE
END IF
C
C reserved for analysis and
C spreading algorithms
C
C open output FG
VER = OFGVER
LUN = LUNTMP (1)
CALL FLGINI ('WRIT', FGBUF1, DISKIN, OLDCNO, VER, CATBLK, LUN,
* IFGRNO, FGKOLS, FGNUMV, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'OPENING OUTPUT FG TABLE'
GO TO 990
END IF
NODD = 0
DO 800 IT = 1,NTIMES
IA1 = 1
IA2 = 0
DO 790 IBL = 1,NBL
IA2 = IA2 + 1
IF (IA2.GT.NANT) THEN
IA1 = IA1 + 1
IA2 = IA1
END IF
IC = 0
700 IC = IC + 1
IF (IC.LE.NC) THEN
IF (IFLAG(IC,IBL,IT).LE.0) GO TO 700
JT = IT
710 JT = JT + 1
IF (JT.LE.NTIMES) THEN
IF (IFLAG(IC,IBL,JT).NE.0) GO TO 710
END IF
JT = JT - 1
JC = IC
720 JC = JC + 1
IF (JC.LE.NC) THEN
DO 725 I = IT,JT
IF (IFLAG(JC,IBL,I).EQ.0) GO TO 730
725 CONTINUE
GO TO 720
END IF
730 JC = JC - 1
C flag IC-JC, IT-JT
IFLAGS = 0
DO 740 I = IT,JT
DO 735 J = IC,JC
MM = IFLAG(J,IBL,I)
IF (MM.GT.0) IFLAGS = ZOR (IFLAGS, MM)
IF (MM.EQ.0) THEN
NODD = NODD + 1
MM = 100
END IF
IFLAG(J,IBL,I) = -ABS (MM)
735 CONTINUE
740 CONTINUE
IF (IFLAGS.GT.0) THEN
PFLAGS(1) = ZAND (IFLAGS,1).EQ.1
PFLAGS(2) = ZAND (IFLAGS,2).EQ.2
PFLAGS(3) = ZAND (IFLAGS,4).EQ.4
PFLAGS(4) = ZAND (IFLAGS,8).EQ.8
IFS(1) = IIF
IFS(2) = IIF
CHANS(1) = IC
CHANS(2) = JC
TIMER(1) = TIMES(1,IT) - TEPS
TIMER(2) = TIMES(2,JT) + TEPS
ANTS(1) = IA1
ANTS(2) = IA2
CALL TABFLG ('WRIT', FGBUF1, IFGRNO, FGKOLS, FGNUMV,
* ISU, ISUB, IFQ, ANTS, TIMER, IFS, CHANS, PFLAGS,
* REASON, IRET)
IF (IRET.GT.0) THEN
WRITE (MSGTXT,1000) IRET, 'WRITING OUTPUT FG TABLE'
GO TO 990
END IF
NFGOU = NFGOU + 1
END IF
IC = JC
GO TO 700
END IF
790 CONTINUE
800 CONTINUE
C what we did
WRITE (MSGTXT,1800) NFGOU, IIF, ISU, ISUB, IFQ
CALL MSGWRT (2)
NOUTR = NOUTR + NFGOU
C close
CALL TABFLG ('CLOS', FGBUF1, IFGRNO, FGKOLS, FGNUMV, ISU, ISUB,
* IFQ, ANTS, TIMER, IFS, CHANS, PFLAGS, REASON, IRET)
IF (IRET.GT.0) THEN
WRITE (MSGTXT,1000) IRET, 'CLOSING OUTPUT FG TABLE'
GO TO 990
END IF
C double check
MM = 0
NN = 0
DO 820 IT = 1,NTIMES
DO 815 IBL = 1,NBL
DO 810 IC = 1,NC
IF (IFLAG(IC,IBL,IT).GT.0) MM = MM + 1
IF (IFLAG(IC,IBL,IT).LT.0) NN = NN + 1
810 CONTINUE
815 CONTINUE
820 CONTINUE
WRITE (MSGTXT,1820) MM, NN
IF (MM.GT.0) CALL MSGWRT (2)
WRITE (MSGTXT,1825) NODD, NN
IF (NODD.GT.0) CALL MSGWRT (2)
GO TO 999
C
990 CALL MSGWRT (8)
C
999 RETURN
C-----------------------------------------------------------------------
1000 FORMAT ('REFLFG ERROR:',I4,' ON ',A)
1050 FORMAT ('REFLFG: read ',I9,' flag records IF/Source/Sub/FQ',I3,I4,
* I3,I2)
1075 FORMAT ('REFLFG:',I15,' cells marked')
1150 FORMAT ('Flagged channels between flags ',I12,' channels')
1240 FORMAT ('Flagged for excess over channel ',I12,' times')
1290 FORMAT ('Flagged for excess over time ',I12,' times')
1340 FORMAT ('Flagged for excess over baseline',I12,' times')
1450 FORMAT ('Flagged for excess over antenna',I12,' times')
1800 FORMAT ('REFLFG: wrote',I9,' flag records IF/Source/Sub/FQ',I3,I4,
* I3,I2)
1820 FORMAT ('REFLFG:',I15,' cells still marked',I12,' flagged')
1825 FORMAT ('REFLFG:',I5,' 0-value cells flagged',I12,' flagged')
END
SUBROUTINE REFLHI
C-----------------------------------------------------------------------
C REFLHI adds to input file history
C-----------------------------------------------------------------------
C
INCLUDE 'REFLG.INC'
INTEGER HLUN, IERR, DATE(3), TIME(3), I, IROUND
CHARACTER HILINE*72, CTIME*8, CDATE*12
INCLUDE 'INCS:DMSG.INC'
INCLUDE 'INCS:DDCH.INC'
INCLUDE 'INCS:DCAT.INC'
DATA HLUN /28/
C-----------------------------------------------------------------------
CALL HIINIT (3)
CALL HIOPEN (HLUN, DISKIN, OLDCNO, BUFF1, IERR)
IF (IERR.NE.0) GO TO 900
C Write time and date on new file
CALL ZDATE (DATE)
CALL ZTIME (TIME)
CALL TIMDAT (TIME, DATE, CTIME, CDATE)
WRITE (HILINE,1000) TSKNAM, RLSNAM, CDATE, CTIME
CALL HIADD (HLUN, HILINE, BUFF1, IERR)
IF (IERR.NE.0) GO TO 100
WRITE (HILINE,1010) TSKNAM, IFGVER
CALL HIADD (HLUN, HILINE, BUFF1, IERR)
IF (IERR.NE.0) GO TO 100
WRITE (HILINE,1015) TSKNAM, OFGVER
CALL HIADD (HLUN, HILINE, BUFF1, IERR)
IF (IERR.NE.0) GO TO 100
WRITE (HILINE,1020) TSKNAM, CPARM(1)
CALL HIADD (HLUN, HILINE, BUFF1, IERR)
IF (IERR.NE.0) GO TO 100
IF (FEXT.GT.0) THEN
WRITE (HILINE,1024) TSKNAM, CPARM(2), FEXT
CALL HIADD (HLUN, HILINE, BUFF1, IERR)
IF (IERR.NE.0) GO TO 100
MSGTXT = HILINE(7:)
CALL MSGWRT (4)
END IF
IF (FCHAN.GT.0) THEN
WRITE (HILINE,1025) TSKNAM, CPARM(3), FCHAN
CALL HIADD (HLUN, HILINE, BUFF1, IERR)
IF (IERR.NE.0) GO TO 100
MSGTXT = HILINE(7:)
CALL MSGWRT (4)
END IF
IF (FTIME.GT.0) THEN
WRITE (HILINE,1030) TSKNAM, CPARM(4), FTIME
CALL HIADD (HLUN, HILINE, BUFF1, IERR)
IF (IERR.NE.0) GO TO 100
MSGTXT = HILINE(7:)
CALL MSGWRT (4)
END IF
IF (FBL.GT.0) THEN
WRITE (HILINE,1035) TSKNAM, CPARM(5), FBL
CALL HIADD (HLUN, HILINE, BUFF1, IERR)
IF (IERR.NE.0) GO TO 100
MSGTXT = HILINE(7:)
CALL MSGWRT (4)
END IF
IF (FANTS.GT.0) THEN
WRITE (HILINE,1040) TSKNAM, CPARM(6), FANTS
CALL HIADD (HLUN, HILINE, BUFF1, IERR)
IF (IERR.NE.0) GO TO 100
MSGTXT = HILINE(7:)
CALL MSGWRT (4)
END IF
I = IROUND (CPARM(7))
IF (I.GT.0) THEN
IF (I.EQ.1) THEN
WRITE (HILINE,1045) TSKNAM, I
ELSE
WRITE (HILINE,1046) TSKNAM, I
END IF
CALL HIADD (HLUN, HILINE, BUFF1, IERR)
IF (IERR.NE.0) GO TO 100
END IF
WRITE (HILINE,1050) TSKNAM, NFGSCR, NFGOUT
CALL HIADD (HLUN, HILINE, BUFF1, IERR)
IF (IERR.NE.0) GO TO 100
C Close HI file
100 CALL HICLOS (HLUN, .TRUE., BUFF1, I)
C
900 IF (IERR.NE.0) THEN
MSGTXT = 'UNABLE TO WRITE HISTORY FILE'
CALL MSGWRT (6)
END IF
C
999 RETURN
C-----------------------------------------------------------------------
1000 FORMAT (A6,'RELEASE =''',A7,' '' /********* Start ',A12,2X,A8)
1010 FORMAT (A6,'FLAGVER=',I6,' / input FG table version')
1015 FORMAT (A6,'OUTFGVER=',I5,' / output FG table version')
1020 FORMAT (A6,'CPARM(1)=',F5.1,' / time interval in sec')
1024 FORMAT (A6,'CPARM(2)=',F3.0,' / flagged',I11,' chan between',
* ' flagged chan')
1025 FORMAT (A6,'CPARM(3)=',F5.3,' / flagged',I9,
* ' for excess over channels')
1030 FORMAT (A6,'CPARM(4)=',F5.3,' / flagged',I9,
* ' for excess over time')
1035 FORMAT (A6,'CPARM(5)=',F5.3,' / flagged',I9,
* ' for excess over baselines')
1040 FORMAT (A6,'CPARM(6)=',F5.3,' / flagged',I9,
* ' for excess over antennas')
1045 FORMAT (A6,'CPARM(7)=',I2,' / flag cross-hands if parallel',
* ' flagged')
1046 FORMAT (A6,'CPARM(7)=',I2,' / flag all polarizations if any',
* ' flagged')
1050 FORMAT (A6,'/ input records',I12,' output records',I12)
END
SUBROUTINE REFLGL (IRET)
C-----------------------------------------------------------------------
C REFLGL looks over the output of the baseline-dependent time-freq
C FG records and finds more global flags if possible
C Output:
C IRET I > 0 something bad happened
C-----------------------------------------------------------------------
INTEGER IRET
C
INTEGER MAXFG
PARAMETER (MAXFG=100000)
INCLUDE 'REFLG.INC'
C
CHARACTER PHNAME*48, REASON*24, TREAS*24, ADATE*12, ATIME*8
INTEGER VER, IERR, KEY(2,2), LUN1, LUN2, LUNTMP, IFGRNO, ISU,
* ISUB, IFQ, IANTS(2), IFS(2), ICHANS(2), JSU(MAXFG), JFQ(MAXFG),
* JSUB(MAXFG), JANTS(2,MAXFG), JFS(2,MAXFG), JCHANS(2,MAXFG),
* IFLS, JFLS(MAXFG), DATE(3), TIME(3), NLIST, JLIST, IREC, NREC,
* ZAND, KLIST, MATCH1(MAXFG), NMATCH, IFMAT(MAXIF), NG, IIF, I,
* JIF, NDELIF, ANTMAT(2,MAXANT), MMATCH, NBLANT(MAXANT), IA1,
* IA2, MATCH2(MAXFG), NDELAN, JBL, KIF, KEYSUB(2,2), ICP8
REAL FKEY(2,2), TIMER(2), JTIMER(2,MAXFG), CTIME, TEPS
LOGICAL PFLAGS(4), INONE, DOIF, DOBL
INCLUDE 'INCS:DMSG.INC'
INCLUDE 'INCS:DDCH.INC'
INCLUDE 'INCS:DCAT.INC'
DATA KEY /5,0, 1,0/
DATA FKEY /1.0,0.0, 1.0,0.0/
DATA KEYSUB /4*1/
C-----------------------------------------------------------------------
ICP8 = CPARM(8) + 0.1
DOIF = ICP8.LE.1
DOBL = (ICP8.LE.0) .OR. ((ICP8/2)*2.EQ.ICP8)
TEPS = 0.05 / (24.0 * 3600.0)
NDELIF = 0
NDELAN = 0
CALL FILL (MAXANT, 0, NBLANT)
DO 20 IA1 = 1,NANT
DO 10 IA2 = IA1,NANT
JBL = NANT * (IA1-1) - ((IA1*(IA1-1))/2) + IA2
IF (BLEXIS(JBL).GT.0) THEN
NBLANT(IA1) = NBLANT(IA1) + 1
NBLANT(IA2) = NBLANT(IA2) + 1
END IF
10 CONTINUE
20 CONTINUE
DO 21 IA1 = 1,NANT
IF (NBLANT(IA1).LE.0) NBLANT(IA1) = 1000
21 CONTINUE
C delete the scratch FG table
C ignore errors here
VER = OFGVER + 1
CALL ZPHFIL ('FG', DISKIN, OLDCNO, VER, PHNAME, IERR)
CALL ZDESTR (DISKIN, PHNAME, IERR)
C CALL DELEXT ('FG', DISKIN, OLDCNO, 'WRWR', BUFF1, FGBUF1, VER,
C * IERR)
C sort the current output to SC
C does not upgrade the header!
C so DELEXT is omitted.
MSGTXT = 'Sorting FG table'
CALL MSGWRT (2)
C get size of input
LUN1 = LUNTMP (1)
CALL FLGINI ('READ', FGBUF1, DISKIN, OLDCNO, OFGVER, CATBLK, LUN1,
* IFGRNO, FGKOLS, FGNUMV, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'OPENING INPUT FG TABLE'
GO TO 990
END IF
CALL TABFLG ('CLOS', FGBUF1, IFGRNO, FGKOLS, FGNUMV, ISU, ISUB,
* IFQ, IANTS, TIMER, IFS, ICHANS, PFLAGS, TREAS, IERR)
CALL TABSRT (DISKIN, OLDCNO, 'FG', OFGVER, VER, KEY, KEYSUB, FKEY,
* FGBUF1, CATBLK, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'SORTING OUTPUT FG TABLE TO SC'
GO TO 990
END IF
C set reason for this call
CALL ZDATE (DATE)
CALL ZTIME (TIME)
CALL TIMDAT (TIME, DATE, ATIME, ADATE)
REASON = TSKNAM // ADATE // ATIME(:5)
C open the sorted file read
CALL FLGINI ('READ', FGBUF1, DISKIN, OLDCNO, VER, CATBLK, LUN1,
* IFGRNO, FGKOLS, FGNUMV, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'OPENING SORTED FG TABLE'
GO TO 990
END IF
LUN2 = LUNTMP (1)
CALL FLGINI ('WRIT', FGBUF2, DISKIN, OLDCNO, OFGVER, CATBLK, LUN2,
* OFGRNO, FGKOLS, FGNUMV, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'OPENING SORTED FG TABLE'
GO TO 990
END IF
NREC = FGBUF1(5)
FGBUF2(5) = 0
OFGRNO = 1
CTIME = -1.E6
NLIST = 0
DO 800 IREC = 1,NREC
CALL TABFLG ('READ', FGBUF1, IFGRNO, FGKOLS, FGNUMV, ISU, ISUB,
* IFQ, IANTS, TIMER, IFS, ICHANS, PFLAGS, TREAS, IRET)
IF (IRET.GT.0) THEN
WRITE (MSGTXT,1000) IRET, 'READING SORTED FG SC TABLE'
GO TO 990
END IF
IF (ICHANS(1).LE.0) ICHANS(1) = 1
IF (ICHANS(2).LE.0) ICHANS(2) = NCHAN
IF (IFS(1).LE.0) IFS(1) = 1
IF (IFS(2).LE.0) IFS(2) = NIF
C add to list
IF ((TIMER(1).LE.CTIME) .AND. (NLIST.LE.MAXFG)) THEN
NLIST = NLIST + 1
JSU(NLIST) = ISU
JSUB(NLIST) = ISUB
JFQ(NLIST) = IFQ
JANTS(1,NLIST) = IANTS(1)
JANTS(2,NLIST) = IANTS(2)
JTIMER(1,NLIST) = TIMER(1)
JTIMER(2,NLIST) = TIMER(2)
JFS(1,NLIST) = IFS(1)
JFS(2,NLIST) = IFS(2)
JCHANS(1,NLIST) = ICHANS(1)
JCHANS(2,NLIST) = ICHANS(2)
IFLS = 0
IF (PFLAGS(1)) IFLS = IFLS + 1
IF (PFLAGS(2)) IFLS = IFLS + 2
IF (PFLAGS(3)) IFLS = IFLS + 4
IF (PFLAGS(4)) IFLS = IFLS + 8
JFLS(NLIST) = IFLS
END IF
C process/output list
IF (((TIMER(1).GT.CTIME) .OR. (IREC.EQ.NREC)) .AND.
* (NLIST.GT.0)) THEN
C combine IFs?
JLIST = 0
110 JLIST = JLIST + 1
IF ((JLIST.LT.NLIST) .AND. (DOIF)) THEN
IF (JSU(JLIST).LT.0) GO TO 110
NMATCH = 1
MATCH1(1) = JLIST
KLIST = JLIST
CALL FILL (NIF, 0, IFMAT)
I = JFS(2,KLIST) - JFS(1,KLIST) + 1
CALL FILL (I, 1, IFMAT(JFS(1,KLIST)))
115 KLIST = KLIST + 1
IF (KLIST.LE.NLIST) THEN
IF ((JSU(JLIST).EQ.JSU(KLIST)) .AND.
* (JSUB(JLIST).EQ.JSUB(KLIST)) .AND.
* (JFQ(JLIST).EQ.JFQ(KLIST)) .AND.
* (JFLS(JLIST).EQ.JFLS(KLIST)) .AND.
* (JANTS(1,JLIST).EQ.JANTS(1,KLIST)) .AND.
* (JANTS(2,JLIST).EQ.JANTS(2,KLIST)) .AND.
* (JCHANS(1,JLIST).EQ.JCHANS(1,KLIST)) .AND.
* (JCHANS(2,JLIST).EQ.JCHANS(2,KLIST)) .AND.
C * (ABS(JTIMER(1,JLIST)-JTIMER(1,KLIST)).LE.TEPS)
C * .AND.
* (ABS(JTIMER(2,JLIST)-JTIMER(2,KLIST)).LE.TEPS))
* THEN
NMATCH = NMATCH + 1
MATCH1(NMATCH) = KLIST
I = JFS(2,KLIST) - JFS(1,KLIST) + 1
CALL FILL (I, 1, IFMAT(JFS(1,KLIST)))
END IF
GO TO 115
END IF
C matches?
IF (NMATCH.GT.1) THEN
NG = 0
INONE = .FALSE.
DO 120 IIF = 1,NIF
IF ((.NOT.INONE) .AND. (IFMAT(IIF).GT.0)) THEN
NG = NG + 1
INONE = .TRUE.
ELSE IF ((INONE) .AND. (IFMAT(IIF).LE.0)) THEN
INONE = .FALSE.
END IF
120 CONTINUE
IF (NG.LT.NMATCH) THEN
INONE = .FALSE.
KLIST = 0
DO 125 IIF = 1,NIF
IF (IFMAT(IIF).GT.0) THEN
IF (.NOT.INONE) THEN
JIF = IIF
INONE = .TRUE.
END IF
KIF = IIF
ELSE IF (INONE) THEN
KLIST = KLIST + 1
I = MATCH1(KLIST)
JFS(1,I) = JIF
JFS(2,I) = KIF
INONE = .FALSE.
END IF
125 CONTINUE
IF (INONE) THEN
KLIST = KLIST + 1
I = MATCH1(KLIST)
JFS(1,I) = JIF
JFS(2,I) = KIF
END IF
130 KLIST = KLIST + 1
IF (KLIST.LE.NMATCH) THEN
I = MATCH1(KLIST)
JSU(I) = -999999
NDELIF = NDELIF + 1
GO TO 130
END IF
END IF
END IF
GO TO 110
END IF
C combine baselines
JLIST = 0
210 JLIST = JLIST + 1
IF ((JLIST.LT.NLIST) .AND. (DOBL)) THEN
IF (JSU(JLIST).LT.0) GO TO 210
NMATCH = 1
MMATCH = 1
MATCH1(1) = JLIST
MATCH2(1) = JLIST
KLIST = JLIST
CALL FILL (2*MAXANT, 0, ANTMAT)
IA1 = JANTS(1,JLIST)
IA2 = JANTS(2,JLIST)
IF ((IA1.LE.0) .OR. (IA2.LE.0)) GO TO 210
ANTMAT(1,IA1) = 1
ANTMAT(2,IA2) = 1
215 KLIST = KLIST + 1
IF (KLIST.LE.NLIST) THEN
IF ((JSU(JLIST).EQ.JSU(KLIST)) .AND.
* (JSUB(JLIST).EQ.JSUB(KLIST)) .AND.
* (JFQ(JLIST).EQ.JFQ(KLIST)) .AND.
* (JFLS(JLIST).EQ.JFLS(KLIST)) .AND.
* (JFS(1,JLIST).EQ.JFS(1,KLIST)) .AND.
* (JFS(2,JLIST).EQ.JFS(2,KLIST)) .AND.
* (JCHANS(1,JLIST).EQ.JCHANS(1,KLIST)) .AND.
* (JCHANS(2,JLIST).EQ.JCHANS(2,KLIST)) .AND.
C * (ABS(JTIMER(1,JLIST)-JTIMER(1,KLIST)).LE.TEPS)
C * .AND.
* (ABS(JTIMER(2,JLIST)-JTIMER(2,KLIST)).LE.TEPS))
* THEN
IF (JANTS(1,KLIST).EQ.IA1) THEN
NMATCH = NMATCH + 1
MATCH1(NMATCH) = KLIST
ANTMAT(1,JANTS(1,KLIST)) = 1
ELSE IF (JANTS(2,KLIST).EQ.IA1) THEN
NMATCH = NMATCH + 1
MATCH1(NMATCH) = KLIST
ANTMAT(1,JANTS(2,KLIST)) = 1
END IF
IF (JANTS(1,KLIST).EQ.IA2) THEN
MMATCH = MMATCH + 1
MATCH2(MMATCH) = KLIST
ANTMAT(2,JANTS(1,KLIST)) = 1
ELSE IF (JANTS(2,KLIST).EQ.IA2) THEN
MMATCH = MMATCH + 1
MATCH2(MMATCH) = KLIST
ANTMAT(2,JANTS(2,KLIST)) = 1
END IF
END IF
GO TO 215
END IF
C matches?
IF ((NMATCH.GE.NBLANT(IA1)) .OR. (MMATCH.GE.NBLANT(IA2)))
* THEN
C both antennas
IF ((NMATCH.GE.NBLANT(IA1)) .AND.
* (MMATCH.GE.NBLANT(IA2))) THEN
I = MATCH1(1)
JANTS(1,I) = IA1
JANTS(2,I) = 0
I = MATCH1(2)
JANTS(1,I) = IA2
JANTS(2,I) = 0
DO 220 KLIST = 3,NMATCH
I = MATCH1(KLIST)
JSU(I) = -999999
NDELAN = NDELAN + 1
220 CONTINUE
DO 225 KLIST = 1,MMATCH
I = MATCH2(KLIST)
JSU(I) = -999999
NDELAN = NDELAN + 1
225 CONTINUE
C antenna 1 only
ELSE IF (NMATCH.GE.NBLANT(IA1)) THEN
I = MATCH1(2)
JANTS(1,I) = IA1
JANTS(2,I) = 0
DO 230 KLIST = 3,NMATCH
I = MATCH1(KLIST)
JSU(I) = -999999
NDELAN = NDELAN + 1
230 CONTINUE
C antenna 2 only
ELSE
I = MATCH2(2)
JANTS(1,I) = IA2
JANTS(2,I) = 0
DO 235 KLIST = 3,NMATCH
I = MATCH2(KLIST)
JSU(I) = -999999
NDELAN = NDELAN + 1
235 CONTINUE
END IF
END IF
GO TO 210
END IF
C dump what's left
DO 700 JLIST = 1,NLIST
IF (JSU(JLIST).GE.0) THEN
PFLAGS(1) = ZAND(JFLS(JLIST),1).NE.0
PFLAGS(2) = ZAND(JFLS(JLIST),1).NE.0
PFLAGS(3) = ZAND(JFLS(JLIST),1).NE.0
PFLAGS(4) = ZAND(JFLS(JLIST),1).NE.0
CALL TABFLG ('WRIT', FGBUF2, OFGRNO, FGKOLS, FGNUMV,
* JSU(JLIST), JSUB(JLIST), JFQ(JLIST),
* JANTS(1,JLIST), JTIMER(1,JLIST), JFS(1,JLIST),
* JCHANS(1,JLIST), PFLAGS, REASON, IRET)
IF (IRET.NE.0) THEN
WRITE (MSGTXT,1000) IRET, 'WRITING OUTPUT FG TABLE'
GO TO 990
END IF
END IF
700 CONTINUE
END IF
C start new list
IF ((TIMER(1).GT.CTIME) .AND. (IREC.LT.NREC)) THEN
NLIST = 1
JSU(NLIST) = ISU
JSUB(NLIST) = ISUB
JFQ(NLIST) = IFQ
JANTS(1,NLIST) = IANTS(1)
JANTS(2,NLIST) = IANTS(2)
JTIMER(1,NLIST) = TIMER(1)
JTIMER(2,NLIST) = TIMER(2)
JFS(1,NLIST) = IFS(1)
JFS(2,NLIST) = IFS(2)
JCHANS(1,NLIST) = ICHANS(1)
JCHANS(2,NLIST) = ICHANS(2)
IFLS = 0
IF (PFLAGS(1)) IFLS = IFLS + 1
IF (PFLAGS(2)) IFLS = IFLS + 2
IF (PFLAGS(3)) IFLS = IFLS + 4
IF (PFLAGS(4)) IFLS = IFLS + 8
JFLS(NLIST) = IFLS
CTIME = TIMER(1) + TEPS
END IF
800 CONTINUE
C close FG tables
CALL TABFLG ('CLOS', FGBUF1, IFGRNO, FGKOLS, FGNUMV, ISU, ISUB,
* IFQ, IANTS, TIMER, IFS, ICHANS, PFLAGS, TREAS, IERR)
CALL TABFLG ('CLOS', FGBUF2, OFGRNO, FGKOLS, FGNUMV, ISU, ISUB,
* IFQ, IANTS, TIMER, IFS, ICHANS, PFLAGS, TREAS, IERR)
OFGRNO = OFGRNO - 1
C selection algorithms
WRITE (MSGTXT,1800) NDELIF
CALL MSGWRT (5)
WRITE (MSGTXT,1801) NDELAN
CALL MSGWRT (5)
C new summary
WRITE (MSGTXT,1810) IFGVER, NFGSCR
CALL MSGWRT (5)
WRITE (MSGTXT,1811) NFGOUT
CALL MSGWRT (5)
WRITE (MSGTXT,1812) OFGVER, OFGRNO
CALL MSGWRT (5)
GO TO 999
C
990 CALL MSGWRT (8)
C
999 RETURN
C-----------------------------------------------------------------------
1000 FORMAT ('REFLGL: ERROR',I5,' ON ',A)
1800 FORMAT ('REFLGL: deleted',I8,' records combining IFs')
1801 FORMAT ('REFLGL: deleted',I8,' records combining antennas')
1810 FORMAT ('Input FG version',I5,' has ',I10,' flag records')
1811 FORMAT ('After Time-freq step has ',I10,' flag records')
1812 FORMAT ('Output FG version',I4,' has ',I10,' flag records')
END
|
SUBROUTINE E04UCG(FIRSTV,HITLOW,ISTATE,INFORM,JADD,N,NCTOTL,
* NUMINF,ALFA,PALFA,ATPHIT,BIGALF,BIGBND,PNORM,
* ANORM,AP,AX,BL,BU,FEATOL,P,X)
C MARK 14 RE-ISSUE. NAG COPYRIGHT 1989.
C MARK 16 REVISED. IER-1078 (JUL 1993).
C MARK 17 REVISED. IER-1600 (JUN 1995).
C
C ******************************************************************
C E04UCG finds a step ALFA such that the point x + ALFA*P reaches
C one of the linear constraints (including bounds). Two possible
C steps are defined as follows...
C
C ALFA1 is the maximum step that can be taken without violating
C one of the linear constraints that is currently satisfied.
C ALFA2 reaches a linear constraint that is currently violated.
C Usually this will be the furthest such constraint along P,
C but if FIRSTV = .TRUE. it will be the first one along P.
C This is used only when the problem has been determined to
C be infeasible, and the sum of infeasibilities are being
C minimized. (ALFA2 is not defined if NUMINF = 0.)
C
C ALFA will usually be the minimum of ALFA1 and ALFA2.
C ALFA could be negative (since we allow inactive constraints
C to be violated by as much as FEATOL). In such cases, a
C third possible step is computed, to find the nearest satisfied
C constraint (perturbed by FEATOL) along the direction - P.
C ALFA will be reset to this step if it is shorter. This is the
C only case for which the final step ALFA does not move X exactly
C onto a constraint (the one denoted by JADD).
C
C Constraints in the working set are ignored (ISTATE(j) ge 1).
C
C JADD denotes which linear constraint is reached.
C
C HITLOW indicates whether it is the lower or upper bound that
C has restricted ALFA.
C
C Values of ISTATE(j)....
C
C - 2 - 1 0 1 2 3
C a'x lt bl a'x gt bu a'x free a'x = bl a'x = bu bl = bu
C
C The values -2 and -1 do not occur once a feasible point has been
C found.
C
C Systems Optimization Laboratory, Stanford University.
C Original Fortran 66 version written May 1980.
C This version of E04UCG dated 10-June-1986.
C ******************************************************************
C
C .. Parameters ..
DOUBLE PRECISION ZERO, ONE
PARAMETER (ZERO=0.0D+0,ONE=1.0D+0)
C .. Scalar Arguments ..
DOUBLE PRECISION ALFA, ATPHIT, BIGALF, BIGBND, PALFA, PNORM
INTEGER INFORM, JADD, N, NCTOTL, NUMINF
LOGICAL FIRSTV, HITLOW
C .. Array Arguments ..
DOUBLE PRECISION ANORM(*), AP(*), AX(*), BL(NCTOTL), BU(NCTOTL),
* FEATOL(NCTOTL), P(N), X(N)
INTEGER ISTATE(NCTOTL)
C .. Scalars in Common ..
DOUBLE PRECISION EPSPT3, EPSPT5, EPSPT8, EPSPT9
C .. Local Scalars ..
DOUBLE PRECISION ABSATP, ALFA1, ALFA2, APMAX1, APMAX2, ATP, ATP1,
* ATP2, ATX, PALFA1, PALFA2, RES, ROWNRM
INTEGER I, J, JADD1, JADD2, JS, JSAVE1, JSAVE2
LOGICAL HLOW1, HLOW2, LASTV, NEGSTP, STEP2
C .. External Subroutines ..
EXTERNAL E04UCH
C .. Intrinsic Functions ..
INTRINSIC ABS, MIN
C .. Common blocks ..
COMMON /CE04NB/EPSPT3, EPSPT5, EPSPT8, EPSPT9
C .. Executable Statements ..
C
INFORM = 0
C
C ------------------------------------------------------------------
C First pass -- find steps to perturbed constraints, so that
C PALFA1 will be slightly larger than the true step, and
C PALFA2 will be slightly smaller than it should be.
C In degenerate cases, this strategy gives us some freedom in the
C second pass. The general idea follows that described by P.M.J.
C Harris, p.21 of Mathematical Programming 5, 1 (1973), 1--28.
C ------------------------------------------------------------------
C
NEGSTP = .FALSE.
CALL E04UCH(FIRSTV,NEGSTP,BIGALF,BIGBND,PNORM,JADD1,JADD2,PALFA1,
* PALFA2,ISTATE,N,NCTOTL,ANORM,AP,AX,BL,BU,FEATOL,P,X)
C
JSAVE1 = JADD1
JSAVE2 = JADD2
C
C ------------------------------------------------------------------
C Second pass -- recompute step-lengths without perturbation.
C Amongst constraints that are less than the perturbed steps,
C choose the one (of each type) that makes the largest angle
C with the search direction.
C ------------------------------------------------------------------
ALFA1 = BIGALF
ALFA2 = ZERO
IF (FIRSTV) ALFA2 = BIGALF
C
APMAX1 = ZERO
APMAX2 = ZERO
ATP1 = ZERO
ATP2 = ZERO
HLOW1 = .FALSE.
HLOW2 = .FALSE.
LASTV = .NOT. FIRSTV
C
DO 20 J = 1, NCTOTL
JS = ISTATE(J)
IF (JS.LE.0) THEN
IF (J.LE.N) THEN
ATX = X(J)
ATP = P(J)
ROWNRM = ONE
ELSE
I = J - N
ATX = AX(I)
ATP = AP(I)
ROWNRM = ANORM(I) + ONE
END IF
C
IF (ABS(ATP).LE.EPSPT9*ROWNRM*PNORM) THEN
C
C This constraint appears to be constant along P. It is
C not used to compute the step. Give the residual a value
C that can be spotted in the debug output.
C
RES = -ONE
ELSE IF (ATP.LE.ZERO .AND. JS.NE.-2) THEN
C ---------------------------------------------------------
C a'x is decreasing.
C ---------------------------------------------------------
C The lower bound is satisfied. Test for smaller ALFA1.
C
ABSATP = -ATP
IF (BL(J).GT.(-BIGBND)) THEN
RES = ATX - BL(J)
IF (PALFA1*ABSATP.GE.RES .OR. J.EQ.JSAVE1) THEN
IF (APMAX1*ROWNRM*PNORM.LT.ABSATP) THEN
APMAX1 = ABSATP/(ROWNRM*PNORM)
ALFA1 = RES/ABSATP
JADD1 = J
ATP1 = ATP
HLOW1 = .TRUE.
END IF
END IF
END IF
C
IF (JS.EQ.-1) THEN
C
C The upper bound is violated. Test for either a bigger
C or smaller ALFA2, depending on the value of FIRSTV.
C
RES = ATX - BU(J)
IF ((FIRSTV .AND. PALFA2*ABSATP.GE.RES .OR.
* LASTV .AND. PALFA2*ABSATP.LE.RES)
* .OR. J.EQ.JSAVE2) THEN
IF (APMAX2*ROWNRM*PNORM.LT.ABSATP) THEN
APMAX2 = ABSATP/(ROWNRM*PNORM)
IF (ABSATP.GE.ONE) THEN
ALFA2 = RES/ABSATP
ELSE IF (RES.LT.BIGALF*ABSATP) THEN
ALFA2 = RES/ABSATP
ELSE
ALFA2 = BIGALF
END IF
JADD2 = J
ATP2 = ATP
HLOW2 = .FALSE.
END IF
END IF
END IF
ELSE IF (ATP.GT.ZERO .AND. JS.NE.-1) THEN
C ---------------------------------------------------------
C a'x is increasing and the upper bound is not violated.
C ---------------------------------------------------------
C Test for smaller ALFA1.
C
IF (BU(J).LT.BIGBND) THEN
RES = BU(J) - ATX
IF (PALFA1*ATP.GE.RES .OR. J.EQ.JSAVE1) THEN
IF (APMAX1*ROWNRM*PNORM.LT.ATP) THEN
APMAX1 = ATP/(ROWNRM*PNORM)
ALFA1 = RES/ATP
JADD1 = J
ATP1 = ATP
HLOW1 = .FALSE.
END IF
END IF
END IF
C
IF (JS.EQ.-2) THEN
C
C The lower bound is violated. Test for a new ALFA2.
C
RES = BL(J) - ATX
IF ((FIRSTV .AND. PALFA2*ATP.GE.RES .OR. LASTV .AND.
* PALFA2*ATP.LE.RES) .OR. J.EQ.JSAVE2) THEN
IF (APMAX2*ROWNRM*PNORM.LT.ATP) THEN
APMAX2 = ATP/(ROWNRM*PNORM)
IF (ATP.GE.ONE) THEN
ALFA2 = RES/ATP
ELSE IF (RES.LT.BIGALF*ATP) THEN
ALFA2 = RES/ATP
ELSE
ALFA2 = BIGALF
END IF
JADD2 = J
ATP2 = ATP
HLOW2 = .TRUE.
END IF
END IF
END IF
END IF
C
END IF
20 CONTINUE
C
C ==================================================================
C Determine ALFA, the step to be taken.
C ==================================================================
C In the infeasible case, check whether to take the step ALFA2
C rather than ALFA1...
C
STEP2 = NUMINF .GT. 0 .AND. JADD2 .GT. 0
C
C We do so if ALFA2 is less than ALFA1 or (if FIRSTV is false)
C lies in the range (ALFA1, PALFA1) and has a smaller value of
C ATP.
C
STEP2 = STEP2 .AND. (ALFA2.LT.ALFA1 .OR. LASTV .AND. ALFA2.LE.
* PALFA1 .AND. APMAX2.GE.APMAX1)
C
IF (STEP2) THEN
ALFA = ALFA2
PALFA = PALFA2
JADD = JADD2
ATPHIT = ATP2
HITLOW = HLOW2
ELSE
ALFA = ALFA1
PALFA = PALFA1
JADD = JADD1
ATPHIT = ATP1
HITLOW = HLOW1
C
C If ALFA1 is negative, the constraint to be added (JADD)
C remains unchanged, but ALFA may be shortened to the step
C to the nearest perturbed satisfied constraint along - P.
C
NEGSTP = ALFA .LT. ZERO
IF (NEGSTP) THEN
CALL E04UCH(FIRSTV,NEGSTP,BIGALF,BIGBND,PNORM,JADD1,JADD2,
* PALFA1,PALFA2,ISTATE,N,NCTOTL,ANORM,AP,AX,BL,BU,
* FEATOL,P,X)
C
ALFA = -MIN(ABS(ALFA),PALFA1)
END IF
END IF
C
C Test for undefined or infinite step.
C
IF (JADD.EQ.0) THEN
ALFA = BIGALF
PALFA = BIGALF
END IF
C
IF (ALFA.GE.BIGALF) INFORM = 3
C
RETURN
C
C
C End of E04UCG. (CMALF)
C
END
|
Subroutine Form_Constitutive_Expanded(D,nCMat,iOut)
!********************************************* nCMat MUST be 12 ********************
Implicit Real(kind=8) (a-h,o-z)
!
include 'Material.h'
include 'LogParams.h'
!
Real(kind=8) D
Dimension D(nCMat,nCMat)
!
DATA zero/0.D0/,one/1.0D0/,onem/-1.0D0/,two/2.0D0/,three/3.0D0/
DATA half/0.5D0/,halfm/-0.5D0/,quart/0.25D0/
!----------------------------------------------------------
D = 0.D0 !ALL
!============================== Transformation
XE = zero
! ============================================== engineering <- shell
if(bEng == .TRUE.) then
XE( 1, 1) = one !eb11 <- eb11
XE( 2, 8) = one !eb22 <- eb22
XE( 3, 2) = half !eb12 <- eb12
XE( 3, 7) = half !eb12 <- eb21
XE( 4, 3) = one !eb13 <- eb13
XE( 5, 9) = one !eb23 <- eb23
!
XE( 6, 4) = one !ek11 <- ek11
XE( 7,11) = one !ek22 <- ek22
XE( 8, 5) = half !ek12 <- ek12
XE( 8,10) = half !ek12 <- ek21
write(iOut,1005) (i,(XE(i,j),j=1,nCMat),i=1,8)
else
! ============================================== virtual sym <- virtual
XE( 1, 1) = one !sb11 <- sb11
XE( 2, 8) = one !sb22 <- sb22
XE( 3, 2) = half !sb12 <- sb12
XE( 3, 7) = half !sb12 <- sb21
!
XE( 4, 3) = one !vb13 <- sb13
XE( 5, 9) = one !vb23 <- sb23
XE( 6, 5) = one !sk11 <- sk12
XE( 7,10) = one !sk22 <- sk21
XE( 8, 4) = half !sk12 <- sk11
XE( 8,11) = half !sk12 <- sk22
write(iOut,1010) (i,(XE(i,j),j=1,nCMat),i=1,8)
endif
!============================================================ expanded form
D = MATMUL(TRANSPOSE(XE),MATMUL(CD,XE) )
! =======================================================
write(iOut,1020) (i,(D(i,j),j=1,nCMat),i=1,nCMat)
! ------
return
1005 Format(/ 5x,"Expansion Matrix = ENGINEERING "/
& (2x,I2,12(2x,f5.2)) )
1010 Format(/ 5x,"Expansion Matrix = VIRTUAL "/
& (2x,I2,12(2x,f5.2)) )
1020 Format(/ 5x,"Expanded Constitutive Matrix "/
& (2x,I2,12(2x,f9.2)) )
end
|
12 <--SHAPES
12 <--LINES
id1
2 <--TYPE
639 <--LEFT
14 <--TOP
70 <--WIDTH
30 <--HEIGHT
16777215 <--BACKCOLOR
0 <--BORDERCOLOR
0 <--BORDERCOLOR
-reserved 1-
-reserved 2-
START
id2
2 <--TYPE
638 <--LEFT
549 <--TOP
70 <--WIDTH
30 <--HEIGHT
16777215 <--BACKCOLOR
0 <--BORDERCOLOR
0 <--BORDERCOLOR
-reserved 1-
-reserved 2-
STOP
id3
91 <--TYPE
600 <--LEFT
196 <--TOP
148 <--WIDTH
40 <--HEIGHT
16777215 <--BACKCOLOR
0 <--BORDERCOLOR
0 <--BORDERCOLOR
-reserved 1-
-reserved 2-
INPUT
sayi gir
x
id4
92 <--TYPE
613 <--LEFT
396 <--TOP
120 <--WIDTH
50 <--HEIGHT
16777215 <--BACKCOLOR
0 <--BORDERCOLOR
0 <--BORDERCOLOR
-reserved 1-
-reserved 2-
IF_LESS
sayac
10
id5
3 <--TYPE
922 <--LEFT
213 <--TOP
10 <--WIDTH
10 <--HEIGHT
16777215 <--BACKCOLOR
0 <--BORDERCOLOR
0 <--BORDERCOLOR
-reserved 1-
-reserved 2-
INTERSECTION
id6
3 <--TYPE
922 <--LEFT
411 <--TOP
10 <--WIDTH
10 <--HEIGHT
16777215 <--BACKCOLOR
0 <--BORDERCOLOR
0 <--BORDERCOLOR
-reserved 1-
-reserved 2-
INTERSECTION
id7
91 <--TYPE
571 <--LEFT
61 <--TOP
220 <--WIDTH
40 <--HEIGHT
16777215 <--BACKCOLOR
0 <--BORDERCOLOR
0 <--BORDERCOLOR
-reserved 1-
-reserved 2-
OUTPUT
lütfen sayilari giriniz
id9
0 <--TYPE
590 <--LEFT
251 <--TOP
156 <--WIDTH
30 <--HEIGHT
16777215 <--BACKCOLOR
0 <--BORDERCOLOR
0 <--BORDERCOLOR
-reserved 1-
-reserved 2-
ADD
sayac
1
sayac
id8
0 <--TYPE
634 <--LEFT
114 <--TOP
92 <--WIDTH
30 <--HEIGHT
16777215 <--BACKCOLOR
0 <--BORDERCOLOR
0 <--BORDERCOLOR
-reserved 1-
-reserved 2-
DEFINITION
sayac
0
id10
0 <--TYPE
572 <--LEFT
294 <--TOP
196 <--WIDTH
30 <--HEIGHT
16777215 <--BACKCOLOR
0 <--BORDERCOLOR
0 <--BORDERCOLOR
-reserved 1-
-reserved 2-
ADD
x
toplam
toplam
id11
91 <--TYPE
604 <--LEFT
481 <--TOP
148 <--WIDTH
40 <--HEIGHT
16777215 <--BACKCOLOR
0 <--BORDERCOLOR
0 <--BORDERCOLOR
-reserved 1-
-reserved 2-
OUTPUT
toplam
toplam
id12
0 <--TYPE
629 <--LEFT
156 <--TOP
100 <--WIDTH
30 <--HEIGHT
16777215 <--BACKCOLOR
0 <--BORDERCOLOR
0 <--BORDERCOLOR
-reserved 1-
-reserved 2-
DEFINITION
toplam
0
---- LINES ---- from,to ----
id1,id7
reserved 1
id7,id8
reserved 1
id4,id6
reserved 1
EVET
id6,id5
reserved 1
id5,id3
reserved 1
id8,id12
reserved 1
id12,id3
reserved 1
id3,id9
reserved 1
id9,id10
reserved 1
id10,id4
reserved 1
id4,id11
reserved 1
HAYIR
id11,id2
reserved 1
|
C Last change: LKS 26 Apr 2008 8:15 am
subroutine irrad
c
c core routine on file irrad.f
c
c called by RADANAL [MAIN->RADANAL->IRRAD]
c
c This routine computes various irradiances.
c Mean cosines and the irradiance reflectance are also computed
c and printed.
c Total radiances are used by default, but
c diffuse radiances can be selected by setting totalr = 0.
c Irradiances are _computed_ at all zeta levels, for possible use in
c computing K-functions, etc., but _printout_ is only at selected
c depths, as specified in routine initial.
c
c The zero element of arrays holds the values for zeta = a (in the air)
c
INCLUDE "DIMENS_XL.INC"
COMMON /CRADIF/ RADMa(mxmu,mxphi),RADMz(mxmu,mxphi,mxz),
1 RADPa(mxmu,mxphi),RADPz(mxmu,mxphi,mxz)
COMMON /CRADIR/ RAD0Ma(mxmu,mxphi),RAD0Pa(mxmu,mxphi),
1 RAD0Pz(mxmu,mxphi,mxz)
COMMON /Cgrid/ fmu(mxmu),bndmu(mxmu),omega(mxmu),deltmu(mxmu),
1 zgeo(mxz),zeta(mxz)
COMMON /CgridPhi/phi(mxphi),bndphi(mxphi)
COMMON /Cirrad/ Eou(0:mxz),Eod(0:mxz),Eu(0:mxz),Ed(0:mxz),
1 fMUu(0:mxz),fMUd(0:mxz),fMUtot(0:mxz),R(0:mxz),E2(0:mxz)
COMMON /Cpirrad/ ipirad,izirad(mxz)
COMMON /Cmisc/ imisc(30),fmisc(30)
c
c declare temporary vars
integer nmu, nz
real twopi, wavelen
c set totalr = 1. if total radiances are to be used
c set totalr = 0. if diffuse radiances are to be used
totalr = 1.0
c
nmu = imisc(1)
nphi = imisc(2)
nz = imisc(4)
twopi = 2.*fmisc(1)
DELPHI = 1./FLOAT(nphi)
wavelen = fmisc(13)
c
c compute quantities in the air (at zeta = a)
c
sum1 = 0.
sum2 = 0.
sum3 = 0.
sum4 = 0.
! polar cap
i = nmu
dmu = deltmu(i)
ampM = totalr*RAD0Ma(i,1) + RADMa(i,1)
ampP = totalr*RAD0Pa(i,1)
sum1 = sum1 + ampM * dmu
sum2 = sum2 + ampP * dmu
sum3 = sum3 + ampM*fmu(i) * dmu
sum4 = sum4 + ampP*fmu(i) * dmu
! rest of thetas
do i=1,nmu-1
dmu = deltmu(i)
do iv=1,nphi
ampM = totalr*RAD0Ma(i,iv) + RADMa(i,iv)
ampP = totalr*RAD0Pa(i,iv)
sum1 = sum1 + ampM * dmu * delphi
sum2 = sum2 + ampP * dmu * delphi
sum3 = sum3 + ampM*fmu(i) * dmu * delphi
sum4 = sum4 + ampP*fmu(i) * dmu * delphi
enddo
end do
c
Eou(0) = sum1 * twopi
Eod(0) = sum2 * twopi
Eu(0) = sum3 * twopi
Ed(0) = sum4 * twopi
c
Eo = Eou(0) + Eod(0)
fMUu(0) = Eu(0)/Eou(0)
fMUd(0) = Ed(0)/Eod(0)
fMUtot(0) = (Ed(0) - Eu(0))/Eo
R(0) = Eu(0)/Ed(0)
c
if(imisc(9).ge.0) then
c *write in air values
write(10,200) wavelen
write(10,203) Eou(0),Eod(0),Eo,Eu(0),Ed(0),fMUu(0),
1 fMUd(0),fMUtot(0),R(0)
if(totalr.ne.1.) write(10,201)
else
c ** minimal printout selected
c *write in air values
write(10,300) wavelen
write(10,303) Eo,Eu(0),Ed(0),fMUu(0),
1 fMUd(0),fMUtot(0),R(0)
if(totalr.ne.1.) write(10,201)
endif
c
c Compute quantities within the water (w, ...,zeta, ,,,.m)
c
do iz=1,nz
sum1 = 0.
sum2 = 0.
sum3 = 0.
sum4 = 0.
sum5 = 0.
! polar cap
i = nmu
dmu = deltmu(i)
ampM = totalr*RADMz(i, 1, iz)
ampP = totalr*RADPz(i, 1, iz) +RAD0Pz(i, 1, iz) ! = direct + diffuse
sum1 = sum1 + ampM * dmu
sum2 = sum2 + ampP * dmu
sum3 = sum3 + ampM*fmu(i) * dmu
sum4 = sum4 + ampP*fmu(i) * dmu
sum5 = sum5 + (3.0*fmu(i)*fmu(i) - 1.0)*(ampM + ampP)*dmu * twopi
! rest of thetas
do i=1,nmu-1
dmu = deltmu(i)
do iv=1,nphi
ampM = totalr*RADMz(i, iv, iz)
ampP = totalr*RADPz(i, iv, iz) +RAD0Pz(i, iv, iz) ! = direct + diffuse
sum1 = sum1 + ampM * dmu * delphi
sum2 = sum2 + ampP * dmu * delphi
sum3 = sum3 + ampM*fmu(i) * dmu * delphi
sum4 = sum4 + ampP*fmu(i) * dmu * delphi
sum5 = sum5 + (3.0*fmu(i)*fmu(i)-1.0)*(ampM+ampP)*dmu*delphi
enddo
end do
Eou(iz) = sum1 * twopi
Eod(iz) = sum2 * twopi
Eu(iz) = sum3 * twopi
Ed(iz) = sum4 * twopi
E2(iz) = 0.5*sum5 * twopi
c
Eo = Eou(iz) + Eod(iz)
fMUu(iz) = Eu(iz)/Eou(iz)
fMUd(iz) = Ed(iz)/Eod(iz)
fMUtot(iz) = (Ed(iz) - Eu(iz))/Eo
R(iz) = Eu(iz)/Ed(iz)
c
c check for printout
if(imisc(9).ge.0) then
c *write in water values
iprint = 0
do iiz=1,ipirad
if(iz.eq.izirad(iiz)) iprint = 1
end do
if(iprint.ne.0) write(10,202) iz,zeta(iz),zgeo(iz),Eou(iz),
1 Eod(iz),Eo,Eu(iz),Ed(iz),fMUu(iz),fMUd(iz),fMUtot(iz),R(iz)
else
c ** minimal printout selected
c *write in water values
iprint = 0
do iiz=1,ipirad
if(iz.eq.izirad(iiz)) iprint = 1
end do
if(iprint.ne.0) write(10,302) iz,zeta(iz),zgeo(iz),
1 Eo,Eu(iz),Ed(iz),fMUu(iz),fMUd(iz),fMUtot(iz),R(iz)
endif
c
end do
C
RETURN
C
200 format(///2x,'Irradiances (units of W/m^2 nm), Mean Cosines',
1' (Mubars), and Irradiance Reflectance at ',f6.1,' nm'//
2' iz zeta z(m)',8x,'Eou',12x,'Eod',13x,'Eo',
3 13x,'Eu',13x,'Ed',7x,'MUBARu MUBARd MUBAR',6x,'R = Eu/Ed'/)
201 FORMAT(2x,'NOTE: only the DIFFUSE AMPLITUDES are used to',
1' compute the irradiances')
202 FORMAT(I5,2F7.2,1P,5E15.4,0P,3F9.4,1P,E15.4)
203 FORMAT(11X,'in air',2X,1P,5E15.4,0P,3F9.4,1P,E15.4/)
c
300 format(//2x,'Irradiances (units of W/m^2 nm), Mean Cosines',
1' (Mubars), and Irradiance Reflectance at ',f6.1,' nm'//
2' iz zeta z(m)',8x,'Eo',
3 13x,'Eu',13x,'Ed',7x,'MUBARu MUBARd MUBAR',6x,'R = Eu/Ed'/)
302 FORMAT(I5,2F7.2,1P,3E15.4,0P,3F9.4,1P,E15.4)
303 FORMAT(11X,'in air',2X,1P,3E15.4,0P,3F9.4,1P,E15.4/)
C
END
|
SUBROUTINE F02WCZ(M,N,C,NRC,Z,Q,NRQ)
C MARK 8 RELEASE. NAG COPYRIGHT 1979.
C MARK 11.5(F77) REVISED. (SEPT 1985.)
C WRITTEN BY S. HAMMARLING, MIDDLESEX POLYTECHNIC (HOUGVQ)
C
C F02WCZ RETURNS THE FIRST N COLUMNS OF THE M*M ORTHOGONAL
C MATRIX Q FOR THE FACTORIZATION OF ROUTINE F01QAF. N MUST
C NOT BE LARGER THAN M.
C
C DETAILS OF Q MUST BE SUPPLIED IN THE M*N MATRIX C AND IN
C THE N ELEMENT VECTOR Z AS RETURNED FROM ROUTINE F01QAF.
C
C NRC AND NRQ MUST BE THE ROW DIMENSIONS OF C AND Q
C RESPECTIVELY AS DECLARED IN THE CALLING PROGRAM AND MUST
C EACH BE AT LEAST M.
C
C THE ROUTINE MAY BE CALLED WITH Q=C.
C
C .. Scalar Arguments ..
INTEGER M, N, NRC, NRQ
C .. Array Arguments ..
DOUBLE PRECISION C(NRC,N), Q(NRQ,N), Z(N)
C .. Local Scalars ..
INTEGER I, J, K, KK, KM1, KP1
C .. External Subroutines ..
EXTERNAL F01QAZ
C .. Executable Statements ..
IF (M.EQ.N) Z(N) = 0.0D0
C
K = N
DO 120 KK = 1, N
IF (K.EQ.1) GO TO 40
KM1 = K - 1
C
DO 20 I = 1, KM1
Q(I,K) = 0.0D0
20 CONTINUE
C
40 Q(K,K) = 1.0D0 - Z(K)
IF (K.EQ.M) GO TO 80
KP1 = K + 1
C
DO 60 I = KP1, M
Q(I,K) = -C(I,K)
60 CONTINUE
C
80 IF (K.EQ.1) GO TO 120
C
J = K
DO 100 I = 1, KM1
J = J - 1
C
CALL F01QAZ(M-J+1,C(J,J),Z(J),Q(J,K))
C
100 CONTINUE
C
K = KM1
120 CONTINUE
C
RETURN
END
|
subroutine PPAR4(iprt,idprt,cdate,ctime,iTSAMP,iTPREc,nsamp,nDv,
&iDd,calfac,calvolt,nAc,dnAc,irate,ncjump,ilenc,igapc,ivhold,sampv,
& vjump,control,nAv,dnAv,nvjump,iTPREv,ilenv,igapv,ivolt1,ivolt2,
& amVpA1,ftape,gain,nsweep,swtime,ismode,swval,nkeep,ikeep,kstep,
& jkeep,nsamp1,tkpre,tkpost,iramp)
c To type/print parameter values. Last row of param added for CJUMP2.
c IPRT=0 No print to screen
c IPRT=1 Print brief details to screen
c IPRT=2 Print full details to screen
c IDPRT=0 No print to disc
c IDPRT=1 Print brief details to disc (for each jump recorded)
c IDPRT=2 Print full details to disc (only when params changed)
c Show details for multiple sweeps only when FULL details requested
c and if in graphics mode, details of IKEEP not put on screen even
c then to avoid disturbing boxes.
c (the brief details are to show what happens in individual sweeps)
c
real*4 vstep(10) !for GETSTEP
real*4 swval(30) !values that change between sweeps
integer*4 ilenc(10),igapc(10) !lengths of c-jumps and gaps between them
integer*4 ilenv(10),igapv(10) !lengths of V-jumps and gaps between them
integer*4 iramp
real*4 alenv(10),agapv(10),alenc(10),agapc(10)
integer*2 ivolt1(10),ivolt2(10),ivhold !pots for each V jump (integer mV)
integer*2 ikeep(4,2,30),kstep(5)
character*11 cdate,ctime
character*10 getint
character*13 getreal
character*78 dtext(30,2)
integer*4 videotyp
logical pon,slock,vjump,ramp,sampv,control
logical discprt
common/dp/discprt
common/dtext/ndtext
c
pon()=slock()
c
do 20 i=1,10 !convert to real msec for printing
alenv(i)=1.e-3*float(ilenv(i))
agapv(i)=1.e-3*float(igapv(i))
alenc(i)=1.e-3*float(ilenc(i))
agapc(i)=1.e-3*float(igapc(i))
20 continue
c if(iprt.eq.2) print 60,irate
c if(pon()) write(7,60) irate
c if(idprt.eq.2) write(8,60) irate
c60 format(' Sample rate (Hz) = ',i8)
c===== vstep set to 1 ms for now for interpolation
call GETSTEP(nvjump,ivolt1,ivolt2,ilenv,iDd,nvramp,vstep)
c
idp=idprt
if(.not.discprt) idp=0 !disc file not open
itsamp1=itsamp/1000
c itprec1=itPREc/1000
tprec1=float(itPREc)/1000.
c iTPOSTc=iTSAMP-iTPREc
c Brief print to disc
c============================================================================
if(idp.eq.1.or.iprt.eq.1) then
79 format('&',/)
if(iprt.eq.1) print 70, ctime,itsamp1,ivhold
if(pon()) write(7,70) ctime,itsamp1,ivhold
if(idp.eq.1) write(8,70) ctime,itsamp1,ivhold
70 format(1x,a11,': ADC ',i5,'ms; ','Vhold ',i4)
nchar=36
if(ncjump.gt.0) then
c nchar=nchar+14+8*ncjump
nchar=nchar+14+7*ncjump+7*(ncjump-1) !length + gap
if(nchar.gt.79) then
if(iprt.eq.1) print 79
if(pon()) write(7,79)
if(idp.eq.1) write(8,79)
nchar=0
endif
if(iprt.eq.1) print 72
if(pon()) write(7,72)
if(idp.eq.1) write(8,72)
72 format('&; C-jump (ms) ')
c if(iprt.eq.1) print 73, (alenc(j),j=1,ncjump)
c if(pon()) write(7,73) (alenc(j),j=1,ncjump)
c if(idp.eq.1) write(8,73) (alenc(j),j=1,ncjump)
do 731 j=1,ncjump
if(iprt.eq.1) print 73,alenc(j)
if(pon()) write(7,73) alenc(j)
if(idp.eq.1) write(8,73) alenc(j)
73 format('&',f7.1)
if(j.eq.ncjump) goto 731
if(iprt.eq.1) print 732,agapc(j)
if(pon()) write(7,732) agapc(j)
if(idp.eq.1) write(8,732) agapc(j)
732 format('&(',f7.1,')')
731 continue
endif
if(nvjump.gt.0) then
do 751 i=1,nvjump
if(ivolt1(i).eq.ivolt2(i)) then
nchar=nchar+29
if(nchar.gt.79) then
if(iprt.eq.1) print 79
if(pon()) write(7,79)
if(idp.eq.1) write(8,79)
nchar=0
endif
if(iprt.eq.1) print 74
if(pon()) write(7,74)
if(idp.eq.1) write(8,74)
74 format('&; V-jump ')
if(iprt.eq.1) print 75, alenv(i),ivolt1(i)
if(pon()) write(7,75) alenv(i),ivolt1(i)
if(idp.eq.1) write(8,75) alenv(i),ivolt1(i)
75 format('&',f8.1,'ms to ',i4,'mV')
else
nchar=nchar+36
if(nchar.gt.79) then
if(iprt.eq.1) print 79
if(pon()) write(7,79)
if(idp.eq.1) write(8,79)
nchar=0
endif
if(iprt.eq.1) print 76
if(pon()) write(7,76)
if(idp.eq.1) write(8,76)
76 format('&; V-ramp ')
if(iprt.eq.1) print 77, alenv(i),ivolt1(i),ivolt2(i)
if(pon()) write(7,77) alenv(i),ivolt1(i),ivolt2(i)
if(idp.eq.1) write(8,77)alenv(i),ivolt1(i),ivolt2(i)
77 format('&',f8.1,'ms; ',i4,' to ',i4,'mV;')
endif
751 continue
endif
if(iprt.le.1.and.idp.le.1) RETURN !after brief print
endif
c
c=====================================================================
c
c if(iprt.eq.2) print 61,cdate,ctime,irate,itsamp1,nsamp,iDd
c--------------------------------------------------------------
if(iptr.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=cdate//ctime
ndtext=ndtext+1
dtext(ndtext,2)='Sample rate (Hz) ='//getint(irate,8)
ndtext=ndtext+1
dtext(ndtext,2)='Sample length ='//getint(itsamp1,6)//'ms (
& '//getint(nsamp,6)//'points'
ndtext=ndtext+1
dtext(ndtext,2)='Microseconds between DAC points = '//
& getint(iDd,10)
endif
c------------------------------------------------------------------
if(pon()) write(7,61)cdate,ctime,irate,itsamp1,nsamp,iDd
if(idp.eq.2) write(8,61)cdate,ctime,irate,itsamp1,nsamp,iDd
61 format(1x,a11,3x,a11,/,' Sample rate (Hz) = ',i8,
& ' Sample length = ',i6,' ms (',i6,' points)',/,
& ' Microseconds between DAC points = ',i10)
nline=3
c Print IKEEP etc
292 continue
dx=1.e3/float(irate)
if(nkeep.eq.1.and.ikeep(1,1,1).eq.1.and.
& int4(ikeep(1,2,1)).eq.nsamp) then
c if(iprt.eq.2) print 29
c---------------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=' Whole ADC sample kept'
endif
c------------------------------------------------------------
if(pon()) write(7,29)
if(idp.eq.2) write(8,29)
29 format(' Whole ADC sample kept')
else
c if(iprt.eq.2) print 281,nkeep,nsamp1
c--------------------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=' Number of sections of ADC sample kept = '//
& getint(nkeep,3)//' ('//getint(nsamp1,5)//' points)'
endif
c--------------------------------------------------------------
if(pon()) write(7,281) nkeep,nsamp1
if(idp.eq.2) write(8,281) nkeep,nsamp1
281 format(
& ' Number of sections of ADC sample kept = ',i3,' (',i5,
& ' points)')
c==============================================
c somewhere else!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if(VIDEOTYP().eq.18) goto 981 !don't type rest if in graphics
nline=nline+2
c if(iprt.eq.2) print 98,(kstep(i),i=1,nkeep+1)
if(pon()) write(7,98) (kstep(i),i=1,nkeep+1)
if(idp.eq.2) write(8,98) (kstep(i),i=1,nkeep+1)
98 format(
& ' -Outside specified sections keep also every nth point: n= ',
& 5i3)
n=nsweep
c if(jkeep.le.0) n=1 !same for all sweeps,or same rel to jumps
if(jkeep.eq.0) n=1 !same for all sweeps
c
do 27 m=1,n
nline=nline+1
if(nline.gt.20.and.iprt.gt.0) then
print 650
650 format(' Hit any key to continue')
call ANYKEY
nline=0
endif
if(jkeep.eq.0) then
c if(iprt.eq.2) print 2831
if(pon()) write(7,2831)
if(idp.eq.2) write(8,2831)
2831 format(' For all sweeps:')
else if(jkeep.eq.-1) then
c if(iprt.eq.2) print 284,tkpre,tkpost
if(pon()) write(7,284) tkpre,tkpost
if(idp.eq.2) write(8,284) tkpre,tkpost
284 format(
& ' Keep from ',f8.1,'ms before each C-jump to ',f8.1,
& 'ms after each')
else if(jkeep.eq.-2) then
c if(iprt.eq.2) print 285,tkpre,tkpost
if(pon()) write(7,285) tkpre,tkpost
if(idp.eq.2) write(8,285) tkpre,tkpost
285 format(
& ' Keep from ',f8.1,'ms before each V-jump to ',f8.1,
& 'ms after each')
endif
c else if(jkeep.eq.1) then
if(jkeep.ne.0) then
c also print nsamp1
call CALCNS0(ikeep,nkeep,kstep,nsamp,nsamp1,m)
c if(iprt.eq.2) print 283,m,nsamp1
if(pon()) write(7,283) m,nsamp1
if(idp.eq.2) write(8,283) m,nsamp1
283 format(' For sweep number ',i3,' (',i5,' points kept)')
endif
do 28 i=1,nkeep
t1=float(ikeep(i,1,m)-1)*dx
t2=float(ikeep(i,2,m)-1)*dx
c if(iprt.eq.2) print 282,i,t1,t2,ikeep(i,1,m),ikeep(i,2,m)
if(pon()) write(7,282) i,t1,t2,ikeep(i,1,m),ikeep(i,2,m)
if(idp.eq.2) write(8,282) i,t1,t2,ikeep(i,1,m),ikeep(i,2,m)
282 format(' (',i2,
& ') Keep from ',g13.6,' to ',g13.6,' ms (point ',i5,' to ',i5,')')
nline=nline+1
if(nline.gt.20.and.iprt.gt.0) then
print 650
call ANYKEY
nline=0
endif
28 continue
27 continue
c
endif
c========
c=========================================================
c
981 continue
if(ncjump.eq.0) goto 66
c if(iprt.eq.2) print 65,tPREc1,nAc,dnAc
c--------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=' Concentration jump'
ndtext=ndtext+1
dtext(ndtext,2)='Time to start of (first) C-jump (ms) = '//
& getreal(tprec1,8)
ndtext=ndtext+1
dtext(ndtext,2)='(ie ADC point #'//getint(nax,6)//' is '//
& getreal(dnac,9)// 'microsec before start of C-jump)'
endif
c------------------------------------------------------------
if(pon()) write(7,65) tPREc1,nAc,dnAc
if(idp.eq.2) write(8,65) tPREc1,nAc,dnAc
65 format(
& ' Concentration jump',/,
& ' Time to start of (first) C-jump (ms) = ',f8.2,/,
& ' (ie ADC point #',i6,' is ',f9.2,
& ' microsec before start of C-jump)')
c & ' (ie ADC point #',i6,' coincides with start of C-jump)')
nline=nline+4
if(nline.gt.20.and.iprt.gt.0) then
print 650
call ANYKEY
nline=0
endif
do 62 i=1,ncjump
c if(iprt.eq.2) print 63,i,alenc(i)
c-----------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=' Concentration pulse '//getint(i,2)//
& ':duration (ms)= '//getreal(alenc(i),10)
endif
c------------------------------------------------
if(pon()) write(7,63) i,alenc(i)
if(idp.eq.2) write(8,63) i,alenc(i)
63 format(
& ' Concentration pulse ',i2,': duration (ms) = ',f10.1)
if(i.eq.ncjump) goto 62
c if(iprt.eq.2) print 64,agapc(i)
c--------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)= ' gap between this pulse and next (ms) = '
& //getreal(agapc(i),10 )
endif
c---------------------------------------------------
if(pon()) write(7,64) agapc(i)
if(idp.eq.2) write(8,64) agapc(i)
64 format(
& ' gap between this pulse and next (ms) = ',f10.1)
nline=nline+2
if(nline.gt.20.and.iprt.gt.0) then
print 650
call ANYKEY
nline=0
endif
62 continue
c
66 continue
c if(iprt.eq.2) print 611,ivhold
c-----------------------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=' Holding potential (mV) = '//
& getint(ivhold,4)
endif
c-----------------------------------------------------------------
if(pon()) write(7,611) ivhold
if(idp.eq.2) write(8,611) ivhold
611 format(' Holding potential (mV) = ',i4)
c
if(.not.vjump) RETURN
c
c iTPOSTv=iTSAMP-iTPREv
itprev1=itPREv/1000
c iTPOSTv1=iTPOSTv/1000
c if(iprt.eq.2) print 612,iTPREv1,iTPOSTv1,nAv
c if(pon()) write(7,612) iTPREv1,iTPOSTv1,nAv
c if(idp.eq.2)write(8,612) iTPREv1,iTPOSTv1,nAv
c & ' Sample length (ms): before, after 1st V-jump = ',2i6,/,
c & ' (ie ADC point #',i6,' coincides with start of V-jump)')
c if(iprt.eq.2) print 612,iTPREv1,nAv,dnAv
c-----------------------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=' Voltage jumps/ramps'
ndtext=ndtext+1
dtext(ndtext,2)='Time to start of (first) V-jump (ms) = '
& //getint(itprev1,6)
ndtext=ndtext+1
dtext(ndtext,2)='(ie ADC point #'//getint(nav,6)//' is '//
& getreal(dnav,9)//
& ' microsec before start of V-jump)'
endif
c-----------------------------------------------------------------
if(pon()) write(7,612) iTPREv1,nAv,dnAv
if(idp.eq.2)write(8,612) iTPREv1,nAv,dnAv
612 format(
& ' Voltage jumps/ramps',/,
& ' Time to start of (first) V-jump (ms) = ',i6,/,
& ' (ie ADC point #',i6,' is ',f9.2,
& ' microsec before start of V-jump)')
nline=nline+4
if(nline.gt.20.and.iprt.gt.0) then
print 650
call ANYKEY
nline=0
endif
c
do 621 i=1,nvjump
ramp=ivolt1(i).ne.ivolt2(i) !this one is a ramp
if(.not.ramp) then
c if(iprt.eq.2) print 631,i,alenv(i),ivolt1(i)
c----------------------------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)='#'//getint(i,2)//': Voltage jump; duration
& (ms) = '//getreal(alenv(i),10)//'; potential (mV)'//
& getint(ivolt1(i),4)
endif
c--------------------------------------------------------------------
if(pon()) write(7,631) i,alenv(i),ivolt1(i)
if(idp.eq.2) write(8,631) i,alenv(i),ivolt1(i)
631 format(' #',i2,
& ': Voltage jump; duration (ms) = ',f10.1,'; potential (mV)',i4)
nline=nline+1
else
c if(iprt.eq.2) print 632,i,alenv(i),ivolt1(i),ivolt2(i),vstep(i)
c----------------------------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)='#'//getint(i,2)//': Voltage ramp; duration
& (ms) = '//getreal(alenv(i),10)//'from'//getint(ivolt1(i),5)
& //'mv to'//getint(ivolt2(i),5)
ndtext=ndtext+1
dtext(ndtext,2)='(step size = '//getreal(vstep(i),10)//'mV)'
endif
c--------------------------------------------------------------------
if(pon()) write(7,632) i,alenv(i),ivolt1(i),ivolt2(i),vstep(i)
if(idp.eq.2) write(8,632)i,alenv(i),ivolt1(i),ivolt2(i),
& vstep(i)
632 format(' #',i2,
& ': Voltage ramp; duration (ms) = ',f10.1,'; from',i5,' mV to',i5,
& ' mV',/,' (step size = ',f10.3,' mV)')
nline=nline+2
endif
if(i.eq.nvjump) goto 6211
c if(iprt.eq.2) print 641,agapv(i)
c
c--------------------------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)='gap between this one and next (ms) = '//
& getreal(agapv(i),10)
endif
c--------------------------------------------------------------------
if(pon()) write(7,641) agapv(i)
if(idp.eq.2) write(8,641) agapv(i)
641 format(
& ' gap between this one and next (ms) = ',f10.1)
nline=nline+1
6211 if(nline.gt.20.and.iprt.gt.0) then
print 650
call ANYKEY
nline=0
endif
621 continue
c
if(sampv) then
c if(iprt.eq.2) print 51
c-----------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=' Membrane potential sampled on ADC1'
endif
c------------------------------------------------
if(pon()) write(7,51)
if(idp.eq.2) write(8,51)
51 format(' Membrane potential sampled on ADC1')
endif
if(control) then
c if(iprt.eq.2) print 52
c-----------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=' CONTROL: V-jump only (no C-jump)'
endif
c------------------------------------------------
if(pon()) write(7,52)
if(idp.eq.2) write(8,52)
52 format(' CONTROL: V-jump only (no C-jump)')
endif
c
c Details for multiple sweeps (nsweep,swtime,ismode,swval)
if(nsweep.gt.1) then
c if(iprt.eq.2) print 53,nsweep,swtime
c-----------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=' SERIES of '//getint(nsweeps,3)//'sweeps at
& intervals of '//getreal(swtime,8)//' seconds'
endif
c------------------------------------------------
if(pon()) write(7,53) nsweep,swtime
if(idp.eq.2) write(8,53) nsweep,swtime
53 format(
& ' SERIES of ',i3,' sweeps at intervals of ',f8.2,' seconds')
nline=nline+2
if(ismode.eq.2) then
c if(iprt.eq.2) print 54
c-----------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=' Jump potentials (mV) = '
endif
c------------------------------------------------
if(pon()) write(7,54)
if(idp.eq.2) write(8,54)
54 format(' Jump potentials (mV) = ')
nchar=23
else if(ismode.eq.3) then
c if(iprt.eq.2) print 55
c-----------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=' C-jump lengths (ms) = '
endif
c------------------------------------------------
if(pon()) write(7,55)
if(idp.eq.2) write(8,55)
55 format(' C-jump lengths (ms) = ')
nchar=22
else if(ismode.eq.4) then
c if(iprt.eq.2) print 56
c-----------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=' Gaps bet C-jumps (ms) = '
endif
c------------------------------------------------
if(pon()) write(7,56)
if(idp.eq.2) write(8,56)
56 format(' Gaps bet C-jumps (ms) = ')
nchar=24
endif
if(ismode.gt.1) then
ncl=nchar !number of char printed on each line
do 5 i=1,nsweep
ncl=ncl+7 !number of char printed AFTER next one
80 format('&',f7.1)
81 format(f7.1)
if(ncl.gt.79) then !if next would go past end of line, start new line
c if(iprt.eq.2) print 81,swval(i)
c-----------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=getreal(swval(i),7)
endif
c------------------------------------------------
if(pon()) write(7,81) swval(i)
if(idp.eq.2) write(8,81) swval(i)
nline=nline+1
ncl=7
else
c if(iprt.eq.2) print 80,swval(i)
c-----------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)='&'//getreal(swval(i),7)
endif
c------------------------------------------------
if(pon()) write(7,80) swval(i)
if(idp.eq.2) write(8,80) swval(i)
endif
if(nline.gt.20.and.iprt.gt.0) then
print 650
call ANYKEY
nline=0
endif
5 continue
endif
endif
c========================================
c????????????????????????????????????????
c
c Print calibration
nline=nline+3
if(nline.gt.20.and.iprt.gt.0) then
print 650
call ANYKEY
nline=0
endif
c if(iprt.eq.2) print 50,amVpA1,ftape,gain,calfac,calvolt
c-----------------------------------------------------
if(iprt.eq.2) then
ndtext=ndtext+1
dtext(ndtext,2)=' Calibration: mV/pA = '//getreal(amvpa1,7)
& //': tape factor, gain = '//getreal(ftape,13)//
& getreal(gain,13)
dtext(ndtext,2)=' Current units per ADC unit; calfac = '//
& getreal(calfac,13)
dtext(ndtext,2)=' mV out from clamp per mV membrane pot = '
& //getreal(calvolt,13)
endif
c------------------------------------------------
if(pon()) write(7,50) amVpA1,ftape,gain,calfac,calvolt
if(idp.eq.2) write(8,50) amVpA1,ftape,gain,calfac,calvolt
50 format(
& ' Calibration: mV/pA = ',f7.1,': tape factor, gain = ',2g13.6,/,
& ' Current units per ADC unit; calfac = ',g13.8,/,
& ' mV out from clamp per mV membrane pot = ',g13.6,/)
call defdialog(2,23,2,20,68,icb)
call opendialog(2,7,.true.)
if(ndtext.gt.20) call scroldial(2)
c
RETURN !from PPAR
end
character*(*) function getint(input,n)
call intconv(input,getint)
getint=getint(1:n)
end
character*(*) function getreal(rinput,n)
call realtoch(rinput,getreal,n)
end
|
C$ Disclaimer
C
C THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
C CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
C GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
C ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
C PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
C TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
C WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
C PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
C SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
C SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
C
C IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
C BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
C LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
C INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
C REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
C REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
C
C RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
C THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
C CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
C ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
C
SUBROUTINE NSPSET ( COMMND, ERROR )
IMPLICIT NONE
C March 26, 2003
C
C Added the SET FORMAT DELIMITED command
C
C August 29, 1996
C
C Increase the size of a word from 32 to 80 characters.
C
C Nov 21, 1995
C
C Removed the SET EDITOR command since its already supported
C by the built in command editor code.
C
C Nov 2, 1995
C
C Added the ability to use templates instead of full
C names when requesting information about a column.
C
C Sep 7, 1995
C
C Added DEFAULT INTEGER FORMAT
C DEFAULT FLOATING FORMAT
C
C Synstax and actions to the routine.
C
C Sep 6, 1995
C
C Changed the syntax
C
C from SET TIME FORMAT
C to SET DEFAULT TIME FORMAT
C
C Aug 29, 1995
C
C Added the syntax SET HELP NO WAIT (two words) in addition to
C the original SET HELP NOWAIT.
C
C Aug 15, 1995
C
C Increase the declared length of syntax templates from 120 to 150
C
C
C This routine allows users to set parameters that will be used
C to establish the appearance of reports.
C
CHARACTER*(*) COMMND
CHARACTER*(*) ERROR ( 2 )
CHARACTER*(*) RNAME
PARAMETER ( RNAME = 'NSPSET' )
CHARACTER*(*) RNAMEC
PARAMETER ( RNAMEC = 'NSPSET:' )
C
C SPICELIB functions
C
LOGICAL RETURN
LOGICAL EQSTR
C
C Interface to the SPICELIB error handling.
C
LOGICAL HAVE
C
C Meta/2 functions
C
LOGICAL M2XIST
C
C Parameters used in parsing.
C
INTEGER LNSIZE
PARAMETER ( LNSIZE = 80 )
INTEGER STRING
PARAMETER ( STRING = 1 )
INTEGER INT
PARAMETER ( INT = 2 )
INTEGER OFF
PARAMETER ( OFF = 0 )
INTEGER ASK
PARAMETER ( ASK = 1 )
INTEGER ON
PARAMETER ( ON = 2 )
C
C Meta/2 syntax definition variables.
C
INTEGER LBCELL
PARAMETER ( LBCELL = -5 )
INTEGER WDSIZE
PARAMETER ( WDSIZE = 80 )
INTEGER NUPPER
PARAMETER ( NUPPER = 26 )
INTEGER NSYN
PARAMETER ( NSYN = NUPPER )
INTEGER SYNLEN
PARAMETER ( SYNLEN = 150 )
CHARACTER*(WDSIZE) SYNKEY ( LBCELL : NSYN )
INTEGER SYNPTR ( LBCELL : NSYN )
CHARACTER*(SYNLEN) SYNVAL ( LBCELL : NSYN )
C
C DICTNY
C FLAGGD
C VRBATM
C SPACED
C MARKED
C PLAIN
C FRMMRK
C COLWID
C COLJST
C ALIAS
C COLFMT
C TIMFMT
C PAGEHT
C PAGEWD
C PAGETL
C TLFREQ
C TLJUST
C HDFREQ
C RPTLIM
C AUTOAD
C
INTEGER DICTNY
PARAMETER ( DICTNY = 1 )
INTEGER FLAGGD
PARAMETER ( FLAGGD = DICTNY + 1 )
INTEGER VRBATM
PARAMETER ( VRBATM = FLAGGD + 1 )
INTEGER SPACED
PARAMETER ( SPACED = VRBATM + 1 )
INTEGER MARKED
PARAMETER ( MARKED = SPACED + 1 )
INTEGER PLAIN
PARAMETER ( PLAIN = MARKED + 1 )
INTEGER DELMTD
PARAMETER ( DELMTD = PLAIN + 1 )
INTEGER DELMTS
PARAMETER ( DELMTS = DELMTD + 1 )
INTEGER FRMMRK
PARAMETER ( FRMMRK = DELMTS + 1 )
INTEGER COLWID
PARAMETER ( COLWID = FRMMRK + 1 )
INTEGER COLJST
PARAMETER ( COLJST = COLWID + 1 )
INTEGER ALIAS
PARAMETER ( ALIAS = COLJST + 1 )
INTEGER COLFMT
PARAMETER ( COLFMT = ALIAS + 1 )
INTEGER TIMFMT
PARAMETER ( TIMFMT = COLFMT + 1 )
INTEGER PAGEHT
PARAMETER ( PAGEHT = TIMFMT + 1 )
INTEGER PAGEWD
PARAMETER ( PAGEWD = PAGEHT + 1 )
INTEGER PAGETL
PARAMETER ( PAGETL = PAGEWD + 1 )
INTEGER TLFREQ
PARAMETER ( TLFREQ = PAGETL + 1 )
INTEGER TLJUST
PARAMETER ( TLJUST = TLFREQ + 1 )
INTEGER HDFREQ
PARAMETER ( HDFREQ = TLJUST + 1 )
INTEGER RPTLIM
PARAMETER ( RPTLIM = HDFREQ + 1 )
INTEGER AUTOAD
PARAMETER ( AUTOAD = RPTLIM + 1 )
INTEGER HPAUSE
PARAMETER ( HPAUSE = AUTOAD + 1 )
INTEGER INTFMT
PARAMETER ( INTFMT = HPAUSE + 1 )
INTEGER DPFMT
PARAMETER ( DPFMT = INTFMT + 1 )
C
C There are seven different formats supported. The names
C associated with these formats shall be regarded as
C global variables. We need arrays to hold these names.
C
INTEGER NFMT
PARAMETER ( NFMT = 8 )
CHARACTER*(WDSIZE) FMT ( NFMT )
CHARACTER*(WDSIZE) FORM ( NFMT )
C
C Local Variables
C
CHARACTER*(1) BS
CHARACTER*(WDSIZE) ATTR
CHARACTER*(WDSIZE) COLNAM
CHARACTER*(WDSIZE) LITNAM
CHARACTER*(WDSIZE) ITEM
CHARACTER*(WDSIZE) NAME
CHARACTER*(WDSIZE) TEMP
CHARACTER*(WDSIZE) QUOTE
CHARACTER*(WDSIZE) DELIM
CHARACTER*(LNSIZE) SVALUE
CHARACTER*(LNSIZE) MARGIN
INTEGER ATYPE
INTEGER I
INTEGER ID
INTEGER IVALUE
INTEGER W
INTEGER N
INTEGER NUMFND
INTEGER P
INTEGER USEID
LOGICAL COLCOM
LOGICAL FIRST
LOGICAL FOUND
C
C Save everything.
C
SAVE
DATA FIRST / .TRUE. /
DATA ( SYNVAL(I), I = -5, 0 )
. / ' ', ' ', ' ', ' ', ' ', ' ' /
DATA ( FMT(I), FORM(I), I = 1,NFMT )
. / 'dict', 'FLAGGED',
. 'flag', 'FLAGGED PRESERVED',
. 'verbat', 'VERBATIM',
. 'spaced', 'SPACED TABULAR ',
. 'marked', 'MARKED TABULAR ',
. 'plain', 'TABULAR',
. 'delimited', 'DELIMITED',
. 'delimited', 'DELIMITED' /
C
C Standard Spicelib error handling.
C
IF ( RETURN() ) THEN
RETURN
END IF
CALL CHKIN ( RNAME )
C
C On the first pass establish the syntax that this routine
C is responsible for recognizing.
C
IF ( FIRST ) THEN
FIRST = .FALSE.
C
C The syntax definitions follow.
C
SYNVAL ( DICTNY ) = 'FORMAT[fmt] '
. // 'FLAGGED[dict] '
SYNVAL ( FLAGGD ) = 'FORMAT[fmt] FLAGGED '
. // 'PRESERVED[flag] '
SYNVAL ( VRBATM ) = 'FORMAT[fmt] VERBATIM[verbat]'
SYNVAL ( SPACED ) = 'FORMAT[fmt] SPACED[spaced] '
. // 'TABULAR '
. //'(0:1){ PRESERVED[preserved] } '
SYNVAL ( MARKED ) = 'FORMAT[fmt] MARKED[marked] '
. // 'TABULAR '
. //'(0:1){ PRESERVED[preserved] } '
SYNVAL ( PLAIN ) = 'FORMAT[fmt] TABULAR[plain] '
. //'(0:1){ PRESERVED[preserved] } '
SYNVAL ( DELMTD ) = 'FORMAT[fmt] DELIMITED[delimited] '
. //'(0:3){ DELIMITER #word(%)[delimiter]'
. //' | QUOTE #word(%)[quote] '
. //' | PRESERVED[preserved] } '
SYNVAL ( DELMTS ) = 'FORMAT[fmt] DELIMITED[delimited] '
. //'(0:3){ DELIMITER SPACE[delimiter] '
. //' | QUOTE #word(%)[quote] '
. //' | PRESERVED[preserved] } '
C
C The syntax below allows the user to change the leadoff
C character that is used for the MARKED TABULAR reports.
C
SYNVAL ( FRMMRK ) = 'FORMAT MARK '
. // '#word(%)[fmtmark] '
C
C Below is the syntax for column attributes that the use
C can control in reports.
C
SYNVAL ( COLWID ) = 'COLUMN #word[colnam] '
. // 'WIDTH #int(8:)[columnwdth] '
SYNVAL ( COLJST ) = 'COLUMN #word[colnam] '
. // 'JUSTIFICATION '
. // '(1:1){ LEFT[left] '
. // ' | RIGHT[right] } '
SYNVAL ( ALIAS ) = 'COLUMN #word[colnam] '
. // 'HEADING (1:)#word[alias]'
SYNVAL ( COLFMT) = 'COLUMN #word[colnam] '
. // 'FORMAT (1:)#word[colfmt]'
C
C The TIME column is always present and has special formatting
C requirements. Users may set these using the command below.
C
SYNVAL ( TIMFMT ) = 'DEFAULT TIME FORMAT '
. // '(1:)#word[timefmt] '
C
C The next set of command syntax definitions give the user
C control over the dimensions of the output.
C
SYNVAL ( PAGEHT ) = 'PAGE HEIGHT '
. // '#int(20:)[pageht] '
SYNVAL ( PAGEWD ) = 'PAGE WIDTH '
. // '#int(40:132)[pagewdth] '
SYNVAL ( PAGETL ) = 'PAGE '
. //'(1:1){ TITLE NONE[notitle] '
. // '| TITLE (1:)#word[pagetitle] }'
C
C The next set of syntax definitions allow the user control
C over titles and their positions within reports.
C
SYNVAL ( TLFREQ ) = 'TITLE FREQUENCY[titlefreq] '
. //'(1:1){ 0[zero] '
. // '| 1ST[first] '
. // '| FIRST[first] '
. // '| ALL[all] '
. // '| EVERY #int(1:)[every] } '
SYNVAL ( TLJUST ) = 'TITLE '
. // 'JUSTIFICATION[titlejustify] '
. //'(1:1){ LEFT[left] '
. // '| RIGHT[right] '
. // '| CENTER[center] } '
C
C The user may use the syntax given below to control the
C frequency with which headers are printed with tabular
C format reports.
C
SYNVAL ( HDFREQ ) = 'HEADER FREQUENCY[headerfreq]'
. //' (1:1){ 0[zero] '
. // '| 1ST[first] '
. // '| FIRST[first] '
. // '| ALL[all] '
. // '| EVERY #int(1:)[every] } '
SYNVAL ( RPTLIM ) = 'DELUGE WARNING #int(1:)[limit]'
SYNVAL ( AUTOAD ) = 'AUTOADJUST[auto] '
. // '(1:1){ OFF[off] '
. // ' | ASK[ask] '
. // ' | ON[on] } '
SYNVAL ( HPAUSE ) = 'HELP[help] '
. // '(1:1){ WAIT[wait] '
. // ' | NO WAIT[nowait] '
. // ' | NOWAIT[nowait] } '
SYNVAL ( INTFMT ) = 'DEFAULT INTEGER FORMAT '
. // '#word[intfmt] '
SYNVAL ( DPFMT ) = 'DEFAULT FLOATING FORMAT '
. // '#word[dpfmt] '
BS = '@'
DO I = 1, NUPPER
CALL REPLCH ( SYNVAL(I), '#', BS, SYNVAL(I) )
END DO
CALL M2INTS ( NSYN, SYNKEY, SYNPTR, SYNVAL )
END IF
C
C See if this command matches a known syntax. If it doesn't
C there is no point in hanging around.
C
CALL M2CHCK ( COMMND, SYNKEY, SYNPTR, SYNVAL, ERROR )
IF ( HAVE(ERROR) ) THEN
CALL PREFIX ( RNAMEC, 1, ERROR(2) )
CALL CHKOUT ( RNAME )
RETURN
END IF
C
C If we get to this point, we have a legitimate command.
C See if the user is trying to set a report attribute or a column
C attribute. For column commands, we extract the column name
C and the attribute of that column that the user is allowed to
C set. The variables used for this are COLNAM, ATTR, and SVALUE
C or IVALUE depending upon whether the attribute is represented
C as a string or integer.
C
C The other attributes control shape and other global
C characteristics of reports. In these cases, we extract the
C characteristics name and value. The variables used here
C are ITEM to hold the name of the control item and SVALUE or
C IVALUE to contain the value of the control item.
C
COLCOM = M2XIST('colnam')
IF ( COLCOM ) THEN
CALL M2GETC ( 'colnam', COMMND, FOUND, LITNAM )
CALL UCASE ( LITNAM, COLNAM )
CALL NAMXPN ( COLNAM, 'COLUMN', ERROR )
IF ( HAVE(ERROR) ) THEN
CALL PREFIX ( RNAMEC, 1, ERROR(2) )
CALL CHKOUT ( RNAME )
RETURN
END IF
IF ( M2XIST('columnwdth') ) THEN
ATTR = 'WIDTH'
ATYPE = INT
CALL M2GETI ( 'columnwdth', COMMND, FOUND, IVALUE )
ELSE IF ( M2XIST('left') ) THEN
ATTR = 'JUSTIFICATION'
ATYPE = STRING
SVALUE = 'LEFT'
ELSE IF ( M2XIST('right') ) THEN
ATTR = 'JUSTIFICATION'
ATYPE = STRING
SVALUE = 'RIGHT'
ELSE IF ( M2XIST('alias') ) THEN
ATTR = 'ALIAS'
ATYPE = STRING
CALL M2GETA ( 'alias', COMMND, FOUND, SVALUE )
ELSE IF ( M2XIST('colfmt') ) THEN
ATTR = 'FORMAT'
ATYPE = STRING
CALL M2GETA ( 'colfmt', COMMND, FOUND, SVALUE )
END IF
ELSE IF ( M2XIST('help') ) THEN
ITEM = 'HELPPROMPT'
ATYPE = INT
IF ( M2XIST('wait') ) THEN
IVALUE = 1
ELSE
IVALUE = 0
END IF
ELSE IF ( M2XIST('fmt') ) THEN
ITEM = 'FORMAT'
ATYPE = STRING
I = 1
DO WHILE ( ( I .LE. NFMT )
. .AND. ( .NOT. M2XIST( FMT(I) ) ) )
I = I + 1
END DO
SVALUE = FORM(I)
IF ( M2XIST('preserved') ) THEN
CALL SUFFIX ( 'PRESERVED', 1, SVALUE )
END IF
IF ( M2XIST( 'delimited' ) ) THEN
DELIM = 'TAB'
QUOTE = '"'
CALL M2GETC ( 'delimiter', COMMND, FOUND, DELIM )
CALL M2GETC ( 'quote', COMMND, FOUND, QUOTE )
IF ( EQSTR( 'SPACE', DELIM ) ) THEN
DELIM = 'SPACE'
END IF
CALL BBPUTC_1 ('POST', 'QUOTE', 1, QUOTE )
CALL BBPUTC_1 ('POST', 'DELIMITER', 1, DELIM )
END IF
ELSE IF ( M2XIST('fmtmark') ) THEN
ITEM = 'FMTMARK'
ATYPE = STRING
CALL M2GETC ( 'fmtmark', COMMND, FOUND, SVALUE )
ELSE IF ( M2XIST('timefmt') ) THEN
ITEM = 'TIMEFMT'
ATYPE = STRING
CALL M2GETA ( 'timefmt', COMMND, FOUND, SVALUE )
C
C If the format entered is one of the SCLK formats we need
C to make sure that the SCLK kernel is loaded for
C that SCLK.
C
CALL NSPCHT ( SVALUE, W )
IF ( HAVE(ERROR) ) THEN
CALL PREFIX ( RNAMEC, 1, ERROR(2) )
CALL CHKOUT ( RNAME )
RETURN
END IF
ELSE IF ( M2XIST('intfmt') ) THEN
ITEM = 'INTFMT'
ATYPE = STRING
CALL M2GETA ( 'intfmt', COMMND, FOUND, SVALUE )
CALL UCASE( SVALUE, TEMP )
IF ( TEMP .EQ. 'DEFAULT' ) THEN
SVALUE = TEMP
END IF
ELSE IF ( M2XIST('dpfmt') ) THEN
ITEM = 'DPFMT'
ATYPE = STRING
CALL M2GETA ( 'dpfmt', COMMND, FOUND, SVALUE )
CALL UCASE( SVALUE, TEMP )
IF ( TEMP .EQ. 'DEFAULT' ) THEN
SVALUE = TEMP
END IF
ELSE IF ( M2XIST('pageht') ) THEN
ITEM = 'PAGEHEIGHT'
ATYPE = INT
CALL M2GETI ( 'pageht', COMMND, FOUND, IVALUE )
ELSE IF ( M2XIST('pagewdth') ) THEN
ITEM = 'PAGEWIDTH'
ATYPE = INT
CALL M2GETI ( 'pagewdth', COMMND, FOUND, IVALUE )
C
C We need to notify the command loop "page margins" routine
C that the pagewidth has been modified.
C
CALL NSPSLR ( 1, IVALUE )
ELSE IF ( M2XIST('pagetitle') ) THEN
ITEM = 'PAGETITLE'
ATYPE = STRING
CALL M2GETA ( 'pagetitle', COMMND, FOUND, SVALUE )
ELSE IF ( M2XIST('notitle') ) THEN
ITEM = 'PAGETITLE'
ATYPE = STRING
SVALUE = ' '
ELSE IF ( M2XIST('titlefreq') ) THEN
ITEM = 'TITLEFREQUENCY'
ATYPE = INT
IF ( M2XIST('zero') ) THEN
IVALUE = -1
ELSE IF ( M2XIST('first') ) THEN
IVALUE = 0
ELSE IF ( M2XIST('all') ) THEN
IVALUE = 1
ELSE IF ( M2XIST('every') ) THEN
CALL M2GETI ( 'every', COMMND, FOUND, IVALUE )
END IF
ELSE IF ( M2XIST('limit') ) THEN
ITEM = 'REPORTLIMIT'
ATYPE = INT
CALL M2GETI ( 'limit', COMMND, FOUND, IVALUE )
ELSE IF ( M2XIST('titlejustify') ) THEN
ITEM = 'TITLEJUSTIFICATION'
ATYPE = STRING
IF ( M2XIST('left') ) THEN
SVALUE = 'LEFT'
ELSE IF ( M2XIST('right') ) THEN
SVALUE = 'RIGHT'
ELSE IF ( M2XIST('center') ) THEN
SVALUE = 'CENTER'
END IF
ELSE IF ( M2XIST('headerfreq') ) THEN
ITEM = 'HEADERFREQUENCY'
ATYPE = INT
IF ( M2XIST('zero') ) THEN
IVALUE = -1
ELSE IF ( M2XIST('first') ) THEN
IVALUE = 0
ELSE IF ( M2XIST('all') ) THEN
IVALUE = 1
ELSE
CALL M2GETI ( 'every', COMMND, FOUND, IVALUE )
END IF
ELSE IF ( M2XIST('auto') ) THEN
ITEM = 'AUTOADJUST'
ATYPE = INT
IF ( M2XIST('off') ) THEN
IVALUE = OFF
ELSE IF ( M2XIST('ask') ) THEN
IVALUE = ASK
ELSE IF ( M2XIST('on' ) ) THEN
IVALUE = ON
END IF
END IF
C
C Now depending upon the type of object we just snagged,
C hand it to the appropriate buffering routine.
C
IF ( COLCOM ) THEN
CALL CLN2ID ( COLNAM, ID, FOUND )
IF ( FOUND ) THEN
C
C Yes. The requested column is recognized so we just
C need to set a couple of values before further processing.
C
USEID = ID
NUMFND = 1
ELSE
C
C Ooops. The column wasn't qualified with a table name.
C See if the column is in some table. If it's in just
C one table, we will show it. If it's in more than one
C say so. If it's not in any of them say so.
C
NUMFND = 0
CALL CLNUM ( N )
DO I = 1, N
CALL CLNID ( I, ID, FOUND )
IF ( FOUND ) THEN
CALL CLGAC ( ID, 'COLNAM', NAME )
P = MAX( 1, INDEX( NAME, '.' ) )
IF ( NAME(P:) .EQ. COLNAM ) THEN
USEID = ID
NUMFND = NUMFND + 1
END IF
END IF
END DO
END IF
IF ( NUMFND .EQ. 0 ) THEN
ERROR(1) = 'There is currently no column having the '
. // 'name ''#''. To obtain a list of the columns '
. // 'that are available you can use the either of'
. // 'the commands: SHOW SUMMARY or SHOW KERNELS'
CALL REPMC ( ERROR(1), '#', LITNAM, ERROR(1) )
CALL CHKOUT( RNAME )
RETURN
ELSE IF ( NUMFND .GT. 1 ) THEN
ERROR(1) = 'The column requested, ''#'', appears in '
. // 'more than one table. To specify the '
. // 'table and column of interest supply both '
. // 'the table and column names separated by '
. // 'a period as in ''TABLE.COLUMN''. '
CALL REPMC ( ERROR(1), '#', LITNAM, ERROR(1) )
CALL CHKOUT ( RNAME )
RETURN
ELSE
ID = USEID
END IF
IF ( ATYPE .EQ. INT ) THEN
CALL CLPAI ( ID, ATTR, IVALUE )
ELSE
CALL CLPAC ( ID, ATTR, SVALUE )
END IF
ELSE
IF ( ATYPE .EQ. INT ) THEN
CALL BBPUTI_1 ( 'POST', ITEM, 1, IVALUE )
ELSE
CALL BBPUTC_1 ( 'POST', ITEM, 1, SVALUE )
END IF
END IF
C
C If we adjusted the page width, we shall want to adjust the
C margins used by META/2 for reporting spelling errors. Every
C place else in Inspekt, looks this up directly. Meta/2 on the
C other hand doesn't know about Inspekt and thus needs to be
C told directly what the margins are.
C
IF ( M2XIST('pagewdth') ) THEN
CALL NSPMRG ( MARGIN )
CALL M2MARG ( MARGIN )
END IF
C
C One final error check, and then we are all done.
C
IF ( HAVE(ERROR) ) THEN
CALL PREFIX ( RNAMEC, 1, ERROR(2) )
CALL CHKOUT ( RNAME )
RETURN
END IF
CALL CHKOUT ( RNAME )
RETURN
END
|
c-------------------------------------------------------------------------------------------------c
program project_euler_59
c-------------------------------------------------------------------------------------------------c
c c
c Find the unique positive integer whose square has the form 1_2_3_4_5_6_7_8_9_0, c
c where each “_” is a single digit. c
c c
c-------------------------------------------------------------------------------------------------c
implicit none
include 'euler.inc'
c parameters used in this program only
integer*8 digits1(1000), digits2(1000), digits3(1000), ndigits1, ndigits2, ndigits3, base
logical found_result
c initialize the base
base = 10
c the limits of the result can be found by taking the square roots of extremes
c 1020304050607080900 ** 0.5 = 1010101010.101010
c 1929394959697989990 ** 0.5 = 1389026623.106264
c Since the last digit of the square is 0 then the square root must end in 0
c therefore 1010101020 < x < 1389026630 and we can increment by 10's
digits1(1) = 0
digits1(2) = 2
digits1(3) = 0
digits1(4) = 1
digits1(5) = 0
digits1(6) = 1
digits1(7) = 0
digits1(8) = 1
digits1(9) = 0
digits1(10) = 1
ndigits1 = 10
found_result = .false.
do while(.not.found_result)
c write(*,fmt='(10(I1))') (digits1(x1), x1=ndigits1,1,-1)
c copy over the digits to a second set of varialbles
ndigits2 = ndigits1
do x1=1,ndigits2
digits2(x1) = digits1(x1)
enddo
c square the number
call big_number_product(digits1,ndigits1,digits2,ndigits2,digits3,ndigits3)
if ((digits3(3).eq.9).and.(digits3(5).eq.8).and.(digits3(7).eq.7).and.(digits3(9).eq.6).and.
. (digits3(11).eq.5).and.(digits3(13).eq.4).and.(digits3(15).eq.3).and.(digits3(17).eq.2).and.
. (digits3(19).eq.1)) then
found_result = .true.
write(*,fmt='(10(I1))') (digits1(x1), x1=ndigits1,1,-1)
write(*,fmt='(19(I1))') (digits3(x1), x1=ndigits3,1,-1)
stop
endif
c increment by 10
digits1(2) = digits1(2) + 1
do x1=2,9
if (digits1(x1).ge.10) then
digits1(x1) = digits1(x1) - 10
digits1(x1+1) = digits1(x1+1) + 1
endif
enddo
enddo
end |
C MODULE SCPCPN
C-----------------------------------------------------------------------
C
C ROUTINE TO PUNCH STATION PCPN PARAMETERS.
C
SUBROUTINE SCPCPN (IPNCH,UNITS,IVPCPN,STAID,IPROC,IPTIME,
* MDRBOX,PCPNCF,IPTWGT,IPSWGT,IPCHAR,STASID,STASWT,ISTAT)
C
CHARACTER*4 UNITS,PMDR,PCODE
CHARACTER*8 CHAR
CHARACTER*80 CARD/' '/
C
INCLUDE 'scommon/dimsta'
INCLUDE 'scommon/dimpcpn'
C
INCLUDE 'uio'
INCLUDE 'scommon/sudbgx'
C
C ================================= RCS keyword statements ==========
CHARACTER*68 RCSKW1,RCSKW2
DATA RCSKW1,RCSKW2 / '
.$Source: /fs/hseb/ob72/rfc/ofs/src/ppinit_punch/RCS/scpcpn.f,v $
. $', '
.$Id: scpcpn.f,v 1.2 1998/04/07 14:57:58 page Exp $
. $' /
C ===================================================================
C
C
C
IF (ISTRCE.GT.0) THEN
WRITE (IOSDBG,160)
CALL SULINE (IOSDBG,1)
ENDIF
C
C SET DEBUG LEVEL
LDEBUG=ISBUG('PCPN')
C
ISTAT=0
C
MCHAR=LEN(CHAR)
C
C PRINT PARAMETER ARRAY VERSION NUMBER
IF (LDEBUG.GT.0) THEN
WRITE (IOSDBG,180) IVPCPN
CALL SULINE (IOSDBG,2)
ENDIF
C
C PUNCH PCPN STATION IDENTIFIER
IF (IPNCH.GT.0) THEN
NPOS=1
CALL UTOCRD (ICDPUN,NPOS,'STAN',4,1,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
CALL UTOCRD (ICDPUN,NPOS,STAID,8,1,CARD,3,0,
* LNUM,IERR)
IF (IERR.GT.0) GO TO 140
CALL UPNCRD (ICDPUN,CARD)
ENDIF
C
C PUNCH 'PCPN' STARTING IN COLUMN 1
NPOS=1
CALL UTOCRD (ICDPUN,NPOS,'PCPN',4,1,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
C
C PUNCH DATA TIME INTERVAL
CALL UINTCH (IPTIME,MCHAR,CHAR,NFILL,IERR)
CALL UTOCRD (ICDPUN,NPOS,CHAR,MCHAR,1,CARD,1,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
C
C PUNCH PROCESSING CODE
PCODE='????'
IF (IPROC.EQ.0) PCODE='NORM'
IF (IPROC.EQ.1) PCODE='ZERO'
IF (IPROC.EQ.2) PCODE='SYN'
CALL UTOCRD (ICDPUN,NPOS,PCODE,4,1,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
C
C PUNCH MDR USAGE OPTION
PMDR='MDR'
IF (MDRBOX.EQ.0) PMDR='NMDR'
CALL UTOCRD (ICDPUN,NPOS,PMDR,4,1,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
C
IF (IPTWGT.GT.0) GO TO 30
C
C PUNCH 'D2'
CALL UTOCRD (ICDPUN,NPOS,'D2',2,1,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
GO TO 50
C
C PUNCH IDENTIFIERS AND WEIGHTS OF STATIONS WITH SIGNIFICANCE WEIGHTS
30 CALL UTOCRD (ICDPUN,NPOS,'SIG(',4,0,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
NSPACE=1
DO 40 I=1,IPTWGT
NCHAR=LEN(STASID(I))
CALL UTOCRD (ICDPUN,NPOS,STASID(I),NCHAR,0,CARD,3,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
CALL UTOCRD (ICDPUN,NPOS,',',1,0,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
IF (I.EQ.IPTWGT) NSPACE=0
NUMDEC=2
CALL URELCH (STASWT(I),MCHAR,CHAR,NUMDEC,NFILL,IERR)
CALL UTOCRD (ICDPUN,NPOS,CHAR,MCHAR,NSPACE,CARD,0,0,
* LNUM,IERR)
IF (IERR.GT.0) GO TO 140
40 CONTINUE
CALL UTOCRD (ICDPUN,NPOS,')',1,1,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
C
50 IF (PCPNCF(1).EQ.1.) GO TO 70
C
C PUNCH CORRECTION FACTORS
IF (PCPNCF(2).EQ.-999.) GO TO 60
C
C TWO CORRECTION FACTORS
CALL UTOCRD (ICDPUN,NPOS,'CF(',3,0,CARD,0,14,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
NUMDEC=2
CALL URELCH (PCPNCF(1),MCHAR,CHAR,NUMDEC,NFILL,IERR)
CALL UTOCRD (ICDPUN,NPOS,CHAR,MCHAR,0,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
CALL UTOCRD (ICDPUN,NPOS,',',1,0,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
CALL URELCH (PCPNCF(2),MCHAR,CHAR,NUMDEC,NFILL,IERR)
CALL UTOCRD (ICDPUN,NPOS,CHAR,MCHAR,0,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
CALL UTOCRD (ICDPUN,NPOS,')',1,1,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
GO TO 70
C
C ONE CORRECTION FACTOR
60 CALL UTOCRD (ICDPUN,NPOS,'CF(',3,0,CARD,0,9,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
NUMDEC=2
CALL URELCH (PCPNCF(1),MCHAR,CHAR,NUMDEC,NFILL,IERR)
CALL UTOCRD (ICDPUN,NPOS,CHAR,MCHAR,0,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
CALL UTOCRD (ICDPUN,NPOS,')',1,1,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
C
C START NEW CARD
CALL UPNCRD (ICDPUN,CARD)
NPOS=6
C
70 IF (IPCHAR.EQ.0) GO TO 120
C
C START NEW CARD
CALL UPNCRD (ICDPUN,CARD)
NPOS=6
C
C PUNCH PRECIPITATION CHARACTERISTICS
CALL RPP1CH (IPCHAR,PXCHR,IERR)
IR=IERR+1
GO TO (80,100,110),IR
WRITE (LP,190) IERR
CALL SUERRS (LP,2,-1)
GO TO 120
80 CALL UTOCRD (ICDPUN,NPOS,'CHAR(',5,0,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
NSPACE=1
DO 90 I=1,12
IF (I.EQ.12) NSPACE=0
VALUE=PXCHR(I)
IF (UNITS.EQ.'METR') THEN
CALL UDUCNV ('IN ','MM ',1,1,PXCHR(I),VALUE,IERR)
ENDIF
NUMDEC=2
IF (VALUE.LT.0.1) NUMDEC=3
CALL URELCH (VALUE,MCHAR,CHAR,NUMDEC,NFILL,IERR)
CALL UTOCRD (ICDPUN,NPOS,CHAR,MCHAR,NSPACE,CARD,0,0,
* LNUM,IERR)
IF (IERR.GT.0) GO TO 140
90 CONTINUE
CALL UTOCRD (ICDPUN,NPOS,')',1,1,CARD,0,0,LNUM,IERR)
IF (IERR.GT.0) GO TO 140
GO TO 120
100 WRITE (LP,200)
CALL SUERRS (LP,2,-1)
ISTAT=1
GO TO 120
110 WRITE (LP,210) IPCHAR
CALL SUERRS (LP,2,-1)
ISTAT=1
C
120 IF (IPSWGT.EQ.1) GO TO 130
C
C PUNCH INDICATOR THAT STATION NOT TO BE USED FOR WEIGHTING
CALL UTOCRD (ICDPUN,NPOS,'NWGT',4,1,CARD,0,0,LNUM,IERR)
C
130 CALL UPNCRD (ICDPUN,CARD)
GO TO 150
C
140 ISTAT=1
C
150 IF (ISTRCE.GT.0) THEN
WRITE (IOSDBG,220)
CALL SULINE (IOSDBG,1)
ENDIF
C
RETURN
C
C- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
C
160 FORMAT (' *** ENTER SCPCPN')
180 FORMAT ('0PARAMETER ARRAY VERSION NUMBER = ',I2)
190 FORMAT ('0*** ERROR - IN SCPCPN - STATUS CODE FROM RPP1CH NOT ',
* 'RECOGNIZED : ',I3)
200 FORMAT ('0*** ERROR - IN SCPCPN - SYSTEM ERROR ACCESSING ',
* 'PRECIPITATION CHARACTERISTICS FILE.')
210 FORMAT ('0*** ERROR - IN SCPCPN - INVALID VALUE OF POINTER TO ',
* 'LOCATION OF CHARACTERISTICS. IPCHAR = ',I5)
220 FORMAT(' *** EXIT SCPCPN')
C
END
|
c****************************************************************************
function ybyx()
c return the ratio of window height to width.
real ybyx
include 'plotcom.h'
ybyx=(naymax-naymin)/(naxmax-naxmin)
end
C********************************************************************
subroutine pfset(isw)
c Set the plot-to-file mode. If switch negative ask from console.
integer isw
include 'plotcom.h'
c Don't switch immediately. Just set the value at the next pltinit.
pfnextsw=isw
goto 1
2 write(*,*)' Plot to file? (0:no,1:hp,2:ps,3:eps)'
read(*,*)pfnextsw
1 if(pfnextsw.eq.-1)goto 2
return
end
C********************************************************************
c Set world to normalized scalings.
c If min and max are both zero, leave as before.
subroutine scalewn(wxmi,wxma,wymi,wyma,lx,ly)
real wxmi,wxma,wymi,wyma
logical lx,ly
include 'plotcom.h'
lxlog=lx
lylog=ly
if(wxmi.lt.0 .or. wxma.lt.0)lxlog=.false.
if(wymi.lt.0 .or. wyma.lt.0)lylog=.false.
if(wxmi.ne.0..or.wxma.ne.0.)then
wxmin=wxmi
wxmax=wxma
if(wxmin.eq.wxmax)then
write(*,*)' SCALEWN warning: wxmin/max coincide;fixing.'
wxmax=wxmax+1.
endif
if(.not.lxlog)w2nx=(naxmax-naxmin)/(wxmax-wxmin)
if(lxlog)w2nx=(naxmax-naxmin)/(log10(wxmax)-log10(wxmin))
endif
if(wymi.ne.0..or.wyma.ne.0.)then
wymin=wymi
wymax=wyma
if(wymin.eq.wymax)then
write(*,*)' SCALEWN warning: wymin/max coincide;fixing.'
wymax=wymax+1.
endif
if(.not.lylog)w2ny=(naymax-naymin)/(wymax-wymin)
if(lylog)w2ny=(naymax-naymin)/(log10(wymax)-log10(wymin))
endif
return
end
c******************************************************************
subroutine fitscale(xmin,xmax,ymin,ymax,lx,ly)
real xmin,xmax,ymin,ymax
logical lx,ly
c include 'plotcom.h'
real xfac,xdelta,fxmin,fymin,fxmax,fymax
integer nxfac
call fitrange(xmin,xmax,6,nxfac,xfac,xdelta,fxmin,fxmax)
call fitrange(ymin,ymax,6,nxfac,xfac,xdelta,fymin,fymax)
call scalewn(fxmin,fxmax,fymin,fymax,lx,ly)
end
c******************************************************************
c Routines for specifying colors by name.
function idarkblue()
idarkblue=1
end
function idarkgreen()
idarkgreen=2
end
function iskyblue()
iskyblue=3
end
function ibrickred()
ibrickred=4
end
function ipurple()
ipurple=5
end
function igold()
igold=6
end
function igray()
igray=7
end
function ilightgray()
ilightgray=8
end
function iblue()
iblue=9
end
function igreen()
igreen=10
end
function icyan()
icyan=11
end
function ired()
ired=12
end
function imagenta()
imagenta=13
end
function iyellow()
iyellow=14
end
function iblack()
iblack=15
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.