C   26/01/79 002210634  MEMBER NAME  LGDCPY   (SOURCE)      FORTRAN
      SUBROUTINE LGDCPY( NP, LGER1)
C
C     S.YAMADA     26-01-79  17:30
C     LAST MODIFICATION  15-10-79  23:20 Y.WATANABE
C
C---- VERSION FOR BOS DATA.  COMPATIBLE WITH THE FINAL NORD-DATA-FORMAT
C
C---- COPIES RAW DATA FROM 'ALGN' TO /CWORK/.
C     BOTH FORMAT CONVERSION AND CALIBRATION ARE SUPPOSED TO BE DONE.
C
C---- OUTPUT:   NP=THE POINTER TO THE 'ALGN'-BANK.
C               LGER1=ADDITIVE ERROR CODE,(=0 IF NO ERROR)
C                    +1  NO CALIBRATION
C                    +2  BUFFER OVERFLOW
C                    +1024  NO REFORMATTING
C
      IMPLICIT INTEGER *2 (H)
#include "cdata.for"
C
#include "clgwork1.for"
C
      COMMON /CLGMSB/ MESVAL(2)
      COMMON/ CLGVRN/ NVRSN(20)
C
      DATA NVCODE/279021615/
      DATA INITP/0/
      IF(INITP.GT.0) GO TO 5
      INITP=1
      IP= IBLN('ALGN')
5     CONTINUE
      NVRSN(1) = NVCODE
C
C---- LOOK FOR THE POINTER OF THE LG-DATA
      LNG = 0
      LGER1 = 0
C     CALL CLOC( NP, 'ALGN',1 )
      NP=IDATA(IP)
      IF(NP.LE.0) GO TO 300
C
C---- FOR THE INPUT DATA
C----        IDATA(NP)=# OF DATA IN HDATA INCLUDING SUB-POINTERS
C                        AND THE NORD-STATUS WORD.
      LNG = IDATA(NP)
      NNP = NP+NP
C
C---- CALIBRATION CHECK
      IF(HDATA(NNP+2).GT.0) GO TO 1
      LGER1 = 1
      MESVAL(2) = HDATA(NNP+2)
    1 CONTINUE
C
C---- EXAMINE IF FORMAT CHANGE IS ALREADY DONE. EXAMINE POINTERS
C
      IF(HDATA(NNP+3).NE.1) GO TO 92
      IPO = 1
        DO 2 K=1,3
        IPK = HDATA(NNP+K+3)
        IF(IPK.LT.IPO) GO TO 92
        IF(MOD(IPK,2).NE.1) GO TO 92
        IPO = IPK
    2   CONTINUE
      IF((IPO-1)/2+3.NE.LNG) GO TO 92
C
C---- FORMAT IS ALREADY CHANGED.
C     DATA IS SIMPLY COPIED  AFTER THE LENGTH CHECK.
  200 LNGC = 4*LNG
      IF(LNGC.LE.11532) GO TO 201
      LNGC = 11532
  201 CALL MVCL(HNORD,0,HDATA,4*NP,LNGC)
      IF(2883-LNG) 91,900,900
C
C
C---- CREATE TEMPORARY 'ALGN'/1
  300 LNG = 3
      HNORD = 0
      HNORML = 0
      LGER1 = 1024
        DO 301 K=1,4
  301   HPOINT(K) = 1
      CALL BCRE(NP,'ALGN',1,LNG,&93,IER)
      CALL BSAW(1,'ALGN')
      CALL BSTR( NP, HNORD, LNG)
      GO TO 100
C
   93 MESVAL(1) = IER
      CALL LGMESG( 3,2)
      GO TO 100
C
C
C---- ERRORS
C
C---- TOO MANY HITS
   91 LGER1 = LGER1+2
        DO 3 K=2,4
        IF( HPOINT(K).GT.5761 ) HPOINT(K) = 5761
    3   CONTINUE
      GO TO 900
C
C---- NO FORMAT CONVERSION HAS BEEN DONE.
   92 LGER1 = LGER1+1024
C
  900 IF(LGER1.EQ.0) GO TO 100
  901 MESVAL(1) = LGER1
      CALL LGMESG( 3, 1)
C
  100 RETURN
      END
