program reading implicit none integer idim,jdim,kdim,tdim parameter(idim=513,jdim=386,kdim=30,tdim=12) real height(6) data height /-0., -26., -75., -200., -500., -1000./ real*8 h8(idim,jdim),mask8(idim,jdim) real h4(idim,jdim),srho(kdim),mask(idim,jdim) integer i,j,k,t print*,height open(11,file='h-rho.dat',form='unformatted') open(12,file='mask.dat',form='unformatted') open(51,file='h4-rho.dat',form='unformatted') read(11)h8 read(12)mask8 close(11) do j=1,jdim do i=1,idim if(mask8(i,j).eq.1.0)then h4(i,j)=h8(i,j) else h4(i,j)=-9999. endif enddo enddo write(51)h4 end