Commit 3c830f0f authored by Espen Sollum's avatar Espen Sollum
Browse files

Reduced size of arrays for readwind. A bug was introduced somewhere

parent 18a00b76
......@@ -73,7 +73,8 @@ subroutine allocatedumarray(ndims,lendim_exp,maxdim,vartype)
else if (ndims.eq.2) then
call allocatedumarray2D_real(ndims,lendim_exp,maxdim)
else if (ndims.eq.3) then
call allocatedumarray3D_real(ndims,lendim_exp,maxdim)
call allocatedumarray3D_real(ndims,lendim_exp,maxdim)
call allocatedumarray3D_real_nt(ndims,lendim_exp,maxdim)
else if (ndims.eq.4) then
call allocatedumarray4D_real(ndims,lendim_exp,maxdim)
end if
......
......@@ -45,212 +45,230 @@
subroutine allocatedumarray1D(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray1D)) deallocate(dumarray1D)
subroutine allocatedumarray1D(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray1D)) deallocate(dumarray1D)
!
allocate(dumarray1D(lendim_exp(1)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
allocate(dumarray1D(lendim_exp(1)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
return
end subroutine allocatedumarray1D
subroutine allocatedumarray2D(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
subroutine allocatedumarray2D(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray2D)) deallocate(dumarray2D)
allocate(dumarray2D(lendim_exp(1),lendim_exp(2)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
if (allocated(dumarray2D)) deallocate(dumarray2D)
allocate(dumarray2D(lendim_exp(1),lendim_exp(2)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end subroutine allocatedumarray2D
subroutine allocatedumarray3D(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray3D)) deallocate(dumarray3D)
allocate(dumarray3D(lendim_exp(1),lendim_exp(2),lendim_exp(3)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
subroutine allocatedumarray4D(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray4D)) deallocate(dumarray4D)
allocate(dumarray4D(lendim_exp(1),lendim_exp(2),lendim_exp(3),lendim_exp(4)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
subroutine allocatedumarray1D_real(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray1D_real)) deallocate(dumarray1D_real)
allocate(dumarray1D_real(lendim_exp(1)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
subroutine allocatedumarray2D_real(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray2D_real)) deallocate(dumarray2D_real)
allocate(dumarray2D_real(lendim_exp(1),lendim_exp(2)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
subroutine allocatedumarray3D_real(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray3D_real)) deallocate(dumarray3D_real)
subroutine allocatedumarray3D(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray3D)) deallocate(dumarray3D)
allocate(dumarray3D(lendim_exp(1),lendim_exp(2),lendim_exp(3)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end subroutine allocatedumarray3D
subroutine allocatedumarray4D(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray4D)) deallocate(dumarray4D)
allocate(dumarray4D(lendim_exp(1),lendim_exp(2),lendim_exp(3),lendim_exp(4)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end subroutine allocatedumarray4D
subroutine allocatedumarray1D_real(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray1D_real)) deallocate(dumarray1D_real)
allocate(dumarray1D_real(lendim_exp(1)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end subroutine allocatedumarray1D_real
subroutine allocatedumarray2D_real(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray2D_real)) deallocate(dumarray2D_real)
allocate(dumarray2D_real(lendim_exp(1),lendim_exp(2)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end subroutine allocatedumarray2D_real
subroutine allocatedumarray3D_real(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray3D_real)) deallocate(dumarray3D_real)
! allocate(dumarray3D_real(lendim_exp(1),lendim_exp(2),lendim_exp(3)))
allocate(dumarray3D_real(0:lendim_exp(1)-1,0:lendim_exp(2)-1,lendim_exp(3)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
subroutine allocatedumarray4D_real(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray4D_real)) deallocate(dumarray4D_real)
allocate(dumarray4D_real(0:lendim_exp(1)-1,0:lendim_exp(2)-1,lendim_exp(3),lendim_exp(4)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
subroutine allocatedumarray1D_int(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray1D_int)) deallocate(dumarray1D_int)
allocate(dumarray1D_int(lendim_exp(1)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
subroutine allocatedumarray2D_int(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray2D_int)) deallocate(dumarray2D_int)
allocate(dumarray2D_int(lendim_exp(1),lendim_exp(2)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
subroutine allocatedumarray3D_int(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray3D_int)) deallocate(dumarray3D_int)
allocate(dumarray3D_int(lendim_exp(1),lendim_exp(2),lendim_exp(3)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
subroutine allocatedumarray1D_char(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray1D_char)) deallocate(dumarray1D_char)
allocate(dumarray1D_char(lendim_exp(1)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
subroutine allocatedumarray2D_char(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray2D_char)) deallocate(dumarray2D_char)
allocate(dumarray2D_char(lendim_exp(1),lendim_exp(2)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
allocate(dumarray3D_real(0:lendim_exp(1)-1,0:lendim_exp(2)-1,lendim_exp(3)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end subroutine allocatedumarray3D_real
subroutine allocatedumarray3D_real_nt(ndims,lendim_exp,maxdim)
! ESO: for time varying 2D fields, just read for current time
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray3D_real_nt)) deallocate(dumarray3D_real_nt)
! allocate(dumarray3D_real(lendim_exp(1),lendim_exp(2),lendim_exp(3)))
allocate(dumarray3D_real_nt(0:lendim_exp(1)-1,0:lendim_exp(2)-1,1))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end subroutine allocatedumarray3D_real_nt
subroutine allocatedumarray4D_real(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray4D_real)) deallocate(dumarray4D_real)
! ESO: set 4th dimension (time) to length 1
allocate(dumarray4D_real(0:lendim_exp(1)-1,0:lendim_exp(2)-1,lendim_exp(3),1))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end subroutine allocatedumarray4D_real
subroutine allocatedumarray1D_int(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray1D_int)) deallocate(dumarray1D_int)
allocate(dumarray1D_int(lendim_exp(1)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end subroutine allocatedumarray1D_int
subroutine allocatedumarray2D_int(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray2D_int)) deallocate(dumarray2D_int)
allocate(dumarray2D_int(lendim_exp(1),lendim_exp(2)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end subroutine allocatedumarray2D_int
subroutine allocatedumarray3D_int(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray3D_int)) deallocate(dumarray3D_int)
allocate(dumarray3D_int(lendim_exp(1),lendim_exp(2),lendim_exp(3)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end subroutine allocatedumarray3D_int
subroutine allocatedumarray1D_char(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray1D_char)) deallocate(dumarray1D_char)
allocate(dumarray1D_char(lendim_exp(1)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end subroutine allocatedumarray1D_char
subroutine allocatedumarray2D_char(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray2D_char)) deallocate(dumarray2D_char)
allocate(dumarray2D_char(lendim_exp(1),lendim_exp(2)))
if (allocated(istart)) deallocate(istart)
allocate(istart(ndims))
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end subroutine allocatedumarray2D_char
......@@ -598,13 +598,15 @@
goto 100
end if
else if (ndims.eq.4) then
iret = &
nf90_get_var( ncid, id_var, dumarray4D_real, istart, icount )
if (iret .ne. nf90_noerr) then
write(*,9100) 'error inquiring var value 4d(2)' // varname, fnamenc
ierr = -5
goto 100
end if
! iret = &
! nf90_get_var( ncid, id_var, dumarray4D_real, istart, icount )
! if (iret .ne. nf90_noerr) then
! write(*,9100) 'error inquiring var value 4d(2)' // varname, fnamenc
! ierr = -5
! goto 100
! end if
! ESO: do not attempt to read all time steps of 4 dimension variables
continue
end if
!!write(75,*)'gridcheck read variable', varname
!c------------- read number of vertical level
......
......@@ -17,8 +17,8 @@ LIBPATH = /usr/lib/
LNK = -o
CMPL = -c
LIBS = -lnetcdf -lnetcdff $(NCOPT)
FFLAGS = -O0 -g -m64 -cpp -mcmodel=medium -fconvert=little-endian -frecord-marker=4 -ffree-form \
-fbacktrace -fcheck=all $(NCOPT)
FFLAGS = -O2 -g -m64 -cpp -mcmodel=medium -fconvert=little-endian -frecord-marker=4 -ffree-form \
-fbacktrace $(NCOPT)
#FFLAGS = -O2 -cpp -fconvert=little-endian -frecord-marker=4 -ffree-form -mcmodel=medium \
-fbacktrace $(NCOPT)
LDFLAGS = $(FFLAGS) -L$(LIBPATH) -I$(INCPATH) $(LIBS)
......
......@@ -57,6 +57,7 @@ module noresm_variables
!c------------ 3D fields ---------------------------------
double precision, allocatable, dimension(:,:,:) :: dumarray3D
real, allocatable, dimension(:,:,:) :: dumarray3D_real
real, allocatable, dimension(:,:,:) :: dumarray3D_real_nt
integer, allocatable, dimension(:,:,:) :: dumarray3D_int
!c------------ 4D fields ---------------------------------
double precision, allocatable, dimension(:,:,:,:) :: dumarray4D
......
......@@ -151,10 +151,10 @@ module par_mod
!*********************************************
! Maximum dimensions of the input mother grids
!*********************************************
integer,parameter :: nxmax=145,nymax=97,nuvzmax=27,nwzmax=27,nzmax=27 !for NorESM with 1.875x2.5 grid: added by mc
! integer,parameter :: nxmax=145,nymax=97,nuvzmax=27,nwzmax=27,nzmax=27 !for NorESM with 1.875x2.5 grid: added by mc
! integer,parameter :: nxmax=145,nymax=97,nuvzmax=33,nwzmax=33,nzmax=33 !for NorESM2
! integer,parameter :: nxmax=144,nymax=96,nuvzmax=33,nwzmax=33,nzmax=33 !for NorESM2 eso
! integer,parameter :: nxmax=288,nymax=192,nuvzmax=33,nwzmax=33,nzmax=33 !eso: new
integer,parameter :: nxmax=288,nymax=192,nuvzmax=33,nwzmax=33,nzmax=33 !eso: new
!integer,parameter :: nxmax=361,nymax=181,nuvzmax=92,nwzmax=92,nzmax=92
!integer,parameter :: nxmax=361,nymax=181,nuvzmax=61,nwzmax=61,nzmax=61
!integer,parameter :: nxmax=721,nymax=361,nuvzmax=64,nwzmax=64,nzmax=64
......
......@@ -456,18 +456,13 @@
!!write(75,*) varname
!!end if
! do jy=0,nymin1
! do ix=0, nxfield-1
if (varname.eq.'PS') then
! ps_tplus1_and_min1(ix,jy,index)=dumarray3D_real(ix+1,jy+1,itime)/time_interval
write(*,*) 'shape(ps_tplus1_and_min1)',shape(ps_tplus1_and_min1)
write(*,*) 'shape(dumarray3D_real)', shape(dumarray3D_real)
! write(*,*) 'shape(ps_tplus1_and_min1)',shape(ps_tplus1_and_min1)
! write(*,*) 'shape(dumarray3D_real)', shape(dumarray3D_real)
ps_tplus1_and_min1(0:nxfield-2,0:nymin1-1,index)=dumarray3D_real(0:nxfield-2,0:nymin1-1, itime)/time_interval
ps_tplus1_and_min1(0:nxfield-1,0:nymin1,index)=dumarray3D_real(0:nxfield-1,0:nymin1, itime)/time_interval
end if
! end do
! end do
end do
iret = nf90_close( ncid )
......
......@@ -462,9 +462,12 @@
ierr = -5
goto 100
end if
else if (ndims.eq.3) then
else if (ndims.eq.3) then
! set icount, istart for time dimesion=1
icount(3) = 1
istart(3) = itime
iret = &
nf90_get_var( ncid, id_var, dumarray3D_real, istart, icount)
nf90_get_var( ncid, id_var, dumarray3D_real_nt, istart, icount)
if (iret .ne. nf90_noerr) then
write(*,9100) 'error inquiring var value ' // varname, fnamenc
ierr = -5
......@@ -482,9 +485,9 @@
! set icount, istart for time dimesion=1
icount(4) = 1
istart(4) = itime
write(*,*)'icount',icount
write(*,*)'istart',istart
iret = nf90_get_var( ncid, id_var, dumarray3D_real, istart, icount)
! write(*,*)'icount',icount
! write(*,*)'istart',istart
iret = nf90_get_var( ncid, id_var, dumarray4D_real, istart, icount)
if (iret .ne. nf90_noerr) then
write(*,9100) 'error inquiring var value ' // varname, fnamenc
ierr = -5
......@@ -497,73 +500,90 @@
! do ix=0, nxfield-1
if (varname.eq.'U') then
! write(*,*) 'shape(u)', shape(uuh)
! write(*,*) 'shape(dum4d)', shape(dumarray4D_real)
do kz=1,nuvz-1 !recall that there is an augmented surface layer where U10 will be stored
uuh(:,:,nuvz+1-kz)=dumarray4D_real(:,:,kz,itime)
do kz=1,nuvz-1 !recall that there is an augmented surface layer where U10 will be stored
uuh(:,:,nuvz+1-kz)=dumarray4D_real(:,:,kz,1)
end do
else if (varname.eq.'V') then
do kz=1,nuvz-1 !recall taht there is an augmented surface layer where V10 will be stored
vvh(:,:,nuvz+1-kz)=dumarray4D_real(:,:,kz,itime)
do kz=1,nuvz-1 !recall taht there is an augmented surface layer where V10 will be stored
vvh(:,:,nuvz+1-kz)=dumarray4D_real(:,:,kz,1)
end do
else if (varname.eq.'OMEGA') then
do kz=1,nuvz-1 !recall that there is an augmented surface layer where W must be defined
wwh(:,:,nuvz+1-kz)=dumarray4D_real(:,:,kz,itime)
wwh(:,:,nuvz+1-kz)=dumarray4D_real(:,:,kz,1)
end do
else if (varname.eq.'T') then
do kz=1,nuvz-1 !recall that there is an augmented surface layer where T must be defined
tth(:,:,nuvz+1-kz,n)=dumarray4D_real(:,:,kz,itime)
do kz=1,nuvz-1 !recall that there is an augmented surface layer where T must be defined
tth(:,:,nuvz+1-kz,n)=dumarray4D_real(:,:,kz,1)
end do
else if (varname.eq.'Q') then
do kz=1,nuvz-1 !recall that there is an augmented surface layer where Q must be defined
qvh(:,:,nuvz+1-kz,n)=dumarray4D_real(:,:,kz,itime)
qvh(:,:,nuvz+1-k