      SUBROUTINE COUNTRYCODE

C     COUNTRYCODE PLACES THE ISO COUNTRY CODES INTO A CHARACTER
C     VARIABLE

c*********************************************************
c
c     Parameters:
c
c      maxcc - number of countries with NODC country codes
c
c*********************************************************

      parameter (maxcc=200)

c**************************************************************
c
c    Character Arrays:
c
c     ncc - array of all possible country codes
c     ncc2 - output country codes to main program
c
c***************************************************************

      character*2 ncc(maxcc)
      character*6 nccx
      character*11 firsttime
      character*80 filename,name

      common /countryc/ ncc
      save firsttime

      if ( firsttime .ne. 'countrycode' ) then
       firsttime='countrycode'
      else
       return
      endif

      infile=-2
c     infile=-1
      call clearstring(filename,80)
      call extraname('sys.inf'//CHAR(0),
     * 'countryname.c2'//CHAR(0),filename)
c     write(6,*) filename
      call fileopen(filename,'rb+'//CHAR(0),infile)
c     write(6,*) 'open'

      ieof=0
      ncountry=0
      do 50 n=1,maxcc

       call clearstring(name,80)
c      write(6,*) 'read',infile,ieof
       call readc2mask(nccx,name,infile,ieof)
       if ( ieof .ne. 0 ) goto 4
c       write(6,*) nccx,name
       ncc(n)=nccx(1:2)
       ncountry=ncountry+1

50    continue
4     continue

c     write(6,*) 'here',ncountry,infile
      call onefileclosefts(infile)

      do 55 n=ncountry+1,maxcc
55     ncc(n)='  '

      return
      end

