c ************************************************************* program peltrans c ************************************************************* c Translates the Peltier ice topography files from asciispecial c format to a chosen output format. Once compiled and linked c you can run interactively or via a shell script or .com c file. You need to input the following lines of information: c c 1. no. of files to process, i.e. from 1 to 22 c 2. type of file to process (0=ice,1=heights) c 3. format of output file(s), e.g. (20i6) c 4. input filename, e.g. top18.asc or ice18.asc c 5. output filename, e.g. top18.dat or ice18.dat c (repeat the previous two lines nf times c where nf is the number of files c you're processing) c integer idat(180,360) real xlons(360),xlats(180) character*80 info character*5 trash character*20 infile,outfile character*5000 big character*79 stline character*50 frmt1 write (*,*) ' ' write (*,*) ' Enter no. of files to process: ' write (*,*) ' ' read (*,*) ntot write (*,*) ' ' write (*,*) ' Enter type of file to process, e.g. ' write (*,*) ' (ice data=0, topographic heights=1): ' write (*,*) ' ' read (*,*) ntype if (ntype .eq. 0) then ndl = 10 else if (ntype .eq. 1) then ndl = 23 end if write (*,*) ' ' write (*,*) ' Enter output file format, e.g. (180i1): ' write (*,*) ' ' read (*,17) frmt1 c ----------------------------------------------------------------- do 200 nf=1,ntot,1 c ----------------------------------------------------------------- write (*,*) ' ' write (*,*) ' Enter input filename: ' write (*,*) ' ' read (*,17) infile 17 format (a) open (7,file=infile,status='old') c Read first blank line. read (7,17) trash c Read information on second line. read (7,17) info c Read rest of header stuff. do 10 i=1,5,1 read (7,17) trash 10 continue c Read latitudes. do 20 i=1,24,1 read (7,17) stline nst = (i-1)*79 + 1 nfi = nst + 78 big(nst:nfi) = stline(1:79) 20 continue open (12,file='tmp.d',status='unknown',recl=5000) write (12,31) big(1:nfi) 31 format (a5000) close (12) open (12,file='tmp.d',status='unknown',recl=5000) read (12,*) (xlats(j),j=1,180,1) close (12,disp='delete') c Read longitudes. do 50 i=1,50,1 read (7,17) stline nst = (i-1)*79 + 1 nfi = nst + 78 big(nst:nfi) = stline(1:79) 50 continue c Open file tmp.d. open (12,file='tmp.d',status='unknown',recl=5000) c Write string to file tmp.d. write (12,31) big(1:nfi) close (12) open (12,file='tmp.d',status='unknown',recl=5000) read (12,*) (xlats(j),j=1,360,1) c Delete file tmp.d. close (12,disp='delete') c Read data. do 150 ilon=1,180,1 write (*,*) ' ilon = ',ilon nst = 1 nfi = 79 nlines = ndl 75 do 80 i=1,nlines,1 read (7,17) stline big(nst:nfi) = stline(1:79) nst = nst + 79 nfi = nfi + 79 80 continue c Open file tmp.d. open (12,file='tmp.d',status='unknown',recl=5000) c Write string to file tmp.d. write (12,31) big(1:nfi-78) close (12) open (12,file='tmp.d',status='unknown',recl=5000) c If there are 360 values in the string, go on to the next c row; otherwise, read another line of data from the input c file and check again for 360 values. Repeat as necessary. read (12,*,err=120) (idat(ilon,j),j=1,360,1) go to 130 120 nlines = 1 close (12,disp='delete') c write (*,*) ' bad ' go to 75 c Delete file tmp.d. 130 close (12,disp='delete') 150 continue close (7) c Subtract 10000 from every depth to get true depth. do 170 i=1,180,1 do 170 j=1,360,1 idat(i,j) = idat(i,j) - 10000 170 continue write (*,*) ' ' write (*,*) ' Enter output filename: ' write (*,*) ' ' read (*,17) outfile open (6,file=outfile,status='new') write (6,259) info 259 format (a80) do 260 i=1,180,1 write (6,frmt1) (idat(i,j),j=1,360,1) 260 continue close (6) c ---------------------------------------------------------------- 200 continue c ---------------------------------------------------------------- stop end