Well, to specify the position of a rectangle in a plane you need 4 numbers, for example the coordinates of top left point and the coordinates of the right bottom point.
I don’t see 4 numbers to specify your rectangle in the program shown.
Try to write it again assuming that you know that coordinates. Write first in a mathematical notation.
Your expression in the loop (the logical expression inside the loop) doesn’t depend on the index i, j so it is not changed from one iteration to the next one. As I told you before coding write it in mathematical notation.
program Make_2D_Model
implicit none
! integer :: a,b,c,s,p, Area
integer :: l,w,Area
integer:: i,j,nx,nz
integer :: idepth
character*1,allocatable,dimension(:, :: icode
nx=1000
nz=500
idepth=100
l=7
w=12
Area = 84
allocate(icode(1:nx,1:nz))
do i=1,nx
do j=1,nz
if(j<=idepth)then
icode(i,j)='1'
elseif(j>idepth)then
icode(i,j)='3'
endif
enddo
enddo
do i=1,nx
do j=1,nz
if ((i-l)*(j-w)<=Area**0.5) then
icode(i,j)='2'
endif
enddo
enddo
open(2012,file=‘model.txt’,status=‘unknown’)
do j=1,nz
write(2012,1000)(icode(i,j),i=1,nx)
enddo
close(2012)
1000 format(a1)