Commit 880e738f authored by Espen Sollum's avatar Espen Sollum
Browse files

Initial commit of branch (9a7b372b2b10e7b0bfd378559465bafc8bbcd18a from...

Initial commit of branch (9a7b372b2b10e7b0bfd378559465bafc8bbcd18a from https://www.flexpart.eu/gitmob/flexpart)
parent 0a27fd20
!**********************************************************************
! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010 *
! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa, *
! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann *
! Copyright 2016 *
! Andreas Stohl, Massimo Cassiani, Petra Seibert, A. Frank, *
! Gerhard Wotawa, Caroline Forster, Sabine Eckhardt, John Burkhart, *
! Harald Sodemann, Ignacio Pisso *
! *
! This file is part of FLEXPART. *
! This file is part of FLEXPART-NorESM *
! *
! FLEXPART is free software: you can redistribute it and/or modify *
! FLEXPART-NorESM is free software: you can redistribute it *
! and/or modify *
! it under the terms of the GNU General Public License as published by*
! the Free Software Foundation, either version 3 of the License, or *
! (at your option) any later version. *
! *
! FLEXPART is distributed in the hope that it will be useful, *
! FLEXPART-NorESM is distributed in the hope that it will be useful, *
! but WITHOUT ANY WARRANTY; without even the implied warranty of *
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
! GNU General Public License for more details. *
! *
! You should have received a copy of the GNU General Public License *
! along with FLEXPART. If not, see <http://www.gnu.org/licenses/>. *
! along with FLEXPART-NorESM. *
! If not, see <http://www.gnu.org/licenses/>. *
!**********************************************************************
program flexpart
program flexpart_NorESM
!*****************************************************************************
! *
! This is the Lagrangian Particle Dispersion Model FLEXPART. *
! This is the Lagrangian Particle Dispersion Model FLEXPART-NorESM. *
! based on FLEXPART version 9.0.1 *
! The main program manages the reading of model run specifications, etc. *
! All actual computing is done within subroutine timemanager. *
! Note: FLEXPRT-NorESM uses meteo files from the NorESM(CAM4 based) *
! climate model in netcdf format. *
! Note: some lines of code to check netcdf files content have been *
! copied/modfied from routines in FLEXPART-WRF *
! *
! Author: A. Stohl *
! Author: *
! A. Stohl 18 May 1996 *
! *
! 18 May 1996 *
! Modified by: *
! M. Cassiani 2016 *
! Nested input not allowed *
! *
!*****************************************************************************
! *
......@@ -59,9 +70,9 @@ program flexpart
! Print the GPL License statement
!*******************************************************
print*,'Welcome to FLEXPART Version 9.0'
print*,'FLEXPART is free software released under the GNU Genera'// &
'l Public License.'
print*,'Welcome to FLEXPART-NorESM Version 1.0'
print*,'FLEXPART-NorESM is free software released under the GNU'// &
'General Public License.'
! Read the pathnames where input/output files are stored
!*******************************************************
......@@ -119,7 +130,7 @@ program flexpart
call readlanduse
! Assign fractional cover of landuse classes to each ECMWF grid point
! Assign fractional cover of landuse classes to each grid point
!********************************************************************
call assignland
......@@ -223,4 +234,4 @@ program flexpart
write(*,*) 'CONGRATULATIONS: YOU HAVE SUCCESSFULLY COMPLETED A FLE&
&XPART MODEL RUN!'
end program flexpart
end program flexpart_NorESM
!**********************************************************************
! Copyright 2016 *
! Andreas Stohl, Massimo Cassiani, Petra Seibert, A. Frank, *
! Gerhard Wotawa, Caroline Forster, Sabine Eckhardt, John Burkhart, *
! Harald Sodemann *
! *
! This file is part of FLEXPART-NorESM *
! *
! FLEXPART-NorESM is free software: you can redistribute it *
! and/or modify *
! it under the terms of the GNU General Public License as published by*
! the Free Software Foundation, either version 3 of the License, or *
! (at your option) any later version. *
! *
! FLEXPART-NorESM is distributed in the hope that it will be useful, *
! but WITHOUT ANY WARRANTY; without even the implied warranty of *
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
! GNU General Public License for more details. *
! *
! You should have received a copy of the GNU General Public License *
! along with FLEXPART-NorESM. *
! If not, see <http://www.gnu.org/licenses/>. *
!**********************************************************************
subroutine allocatedumarray(ndims,lendim_exp,maxdim,vartype)
!*****************************************************************************
! *
! This routine allocate temporary variables for reading netcdf input *
! files from NorESM *
! *
! Author: *
! M. Cassiani 2016 *
! *
! *
!*****************************************************************************
! *
! Variables: *
! vartype type of variable *
! ndims number of dimensions 0,1,2,3 *
! lendim_exp expeceted elemnts in the dimension *
! vartype *
! Constants: *
! *
!*****************************************************************************
use noresm_variables
implicit none
include 'netcdf.inc'
......@@ -6,54 +51,50 @@ subroutine allocatedumarray(ndims,lendim_exp,maxdim,vartype)
if (vartype.eq.nf_double) then
if (ndims.eq.0) then
dumvar=dble(0.0)
dumvar=dble(0.0)
else if (ndims.eq.1) then
call allocatedumarray1D(ndims,lendim_exp,maxdim)
else if (ndims.eq.2) then
call allocatedumarray2D(ndims,lendim_exp,maxdim)
else if (ndims.eq.3) then
call allocatedumarray3D(ndims,lendim_exp,maxdim)
else if (ndims.eq.4) then
call allocatedumarray4D(ndims,lendim_exp,maxdim)
end if
call allocatedumarray1D(ndims,lendim_exp,maxdim)
else if (ndims.eq.2) then
call allocatedumarray2D(ndims,lendim_exp,maxdim)
else if (ndims.eq.3) then
call allocatedumarray3D(ndims,lendim_exp,maxdim)
else if (ndims.eq.4) then
call allocatedumarray4D(ndims,lendim_exp,maxdim)
end if
else if (vartype.eq.nf_float) then
if (ndims.eq.0) then
dumvar_real=0.0
dumvar_real=0.0
else if (ndims.eq.1) then
call allocatedumarray1D_real(ndims,lendim_exp,maxdim)
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)
else if (ndims.eq.4) then
call allocatedumarray4D_real(ndims,lendim_exp,maxdim)
end if
call allocatedumarray1D_real(ndims,lendim_exp,maxdim)
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)
else if (ndims.eq.4) then
call allocatedumarray4D_real(ndims,lendim_exp,maxdim)
end if
else if (vartype.eq.nf_int) then
if (ndims.eq.0) then
dumvar_int=0.0
else if (ndims.eq.1) then
if (ndims.eq.0) then
dumvar_int=0.0
else if (ndims.eq.1) then
call allocatedumarray1D_int(ndims,lendim_exp,maxdim)
else if (ndims.eq.2) then
call allocatedumarray2D_int(ndims,lendim_exp,maxdim)
else if (ndims.eq.3) then
call allocatedumarray3D_int(ndims,lendim_exp,maxdim)
else if (ndims.eq.2) then
call allocatedumarray2D_int(ndims,lendim_exp,maxdim)
else if (ndims.eq.3) then
call allocatedumarray3D_int(ndims,lendim_exp,maxdim)
!else if (ndims.eq.4) then
! call allocatedumarray4D_int(ndims,lendim_exp,maxdim)
end if
end if
else if (vartype.eq.nf_char) then
if (ndims.eq.1) then
call allocatedumarray1D_char(ndims,lendim_exp,maxdim)
else if (ndims.eq.2) then
call allocatedumarray2D_char(ndims,lendim_exp,maxdim)
end if
if (ndims.eq.1) then
call allocatedumarray1D_char(ndims,lendim_exp,maxdim)
else if (ndims.eq.2) then
call allocatedumarray2D_char(ndims,lendim_exp,maxdim)
end if
end if
return
end
\ No newline at end of file
end
!**********************************************************************
! Copyright 2016 *
! Andreas Stohl, Massimo Cassiani, Petra Seibert, A. Frank, *
! Gerhard Wotawa, Caroline Forster, Sabine Eckhardt, John Burkhart, *
! Harald Sodemann *
! *
! This file is part of FLEXPART-NorESM *
! *
! FLEXPART-NorESM is free software: you can redistribute it *
! and/or modify *
! it under the terms of the GNU General Public License as published by*
! the Free Software Foundation, either version 3 of the License, or *
! (at your option) any later version. *
! *
! FLEXPART-NorESM is distributed in the hope that it will be useful, *
! but WITHOUT ANY WARRANTY; without even the implied warranty of *
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
! GNU General Public License for more details. *
! *
! You should have received a copy of the GNU General Public License *
! along with FLEXPART-NorESM. *
! If not, see <http://www.gnu.org/licenses/>. *
!**********************************************************************
!*****************************************************************************
! *
! These routines allocates temporary variables for reading netcdf input *
! files from NorESM *
! *
! Author: *
! M. Cassiani 2016 *
! *
! *
!*****************************************************************************
! *
! Variables: *
! vartype type of variable *
! ndims number of dimensions 0,1,2,3 *
! lendim_exp expeceted elemnts in the dimension *
! *
! Constants: *
! *
!*****************************************************************************
subroutine allocatedumarray1D(ndims,lendim_exp,maxdim)
......@@ -16,8 +57,8 @@
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
return
end
subroutine allocatedumarray2D(ndims,lendim_exp,maxdim)
......@@ -32,8 +73,8 @@
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
return
end
subroutine allocatedumarray3D(ndims,lendim_exp,maxdim)
......@@ -48,13 +89,13 @@
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
return
end
subroutine allocatedumarray4D(ndims,lendim_exp,maxdim)
use noresm_variables
subroutine allocatedumarray4D(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(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)))
......@@ -63,48 +104,48 @@
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
return
end
subroutine allocatedumarray1D_real(ndims,lendim_exp,maxdim)
use noresm_variables
integer 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))
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
return
end
subroutine allocatedumarray2D_real(ndims,lendim_exp,maxdim)
use noresm_variables
integer 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))
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
return
end
subroutine allocatedumarray3D_real(ndims,lendim_exp,maxdim)
use noresm_variables
use noresm_variables
integer maxdim
integer ndims,lendim_exp(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)))
......@@ -113,13 +154,13 @@
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
return
end
subroutine allocatedumarray4D_real(ndims,lendim_exp,maxdim)
use noresm_variables
subroutine allocatedumarray4D_real(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
integer ndims,lendim_exp(maxdim)
if (allocated(dumarray4D_real)) deallocate(dumarray4D_real)
allocate(dumarray4D_real(lendim_exp(1),lendim_exp(2),lendim_exp(3),lendim_exp(4)))
......@@ -128,15 +169,15 @@
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
return
end
subroutine allocatedumarray1D_int(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
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)))
......@@ -145,14 +186,14 @@
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
return
end
subroutine allocatedumarray2D_int(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer 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)))
......@@ -161,12 +202,12 @@
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
return
end
subroutine allocatedumarray3D_int(ndims,lendim_exp,maxdim)
use noresm_variables
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
......@@ -177,13 +218,13 @@
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
return
end
subroutine allocatedumarray1D_char(ndims,lendim_exp,maxdim)
use noresm_variables
subroutine allocatedumarray1D_char(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
......@@ -194,11 +235,11 @@
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
return
end
subroutine allocatedumarray2D_char(ndims,lendim_exp,maxdim)
use noresm_variables
subroutine allocatedumarray2D_char(ndims,lendim_exp,maxdim)
use noresm_variables
integer maxdim
integer ndims,lendim_exp(maxdim)
......@@ -209,5 +250,5 @@
if (allocated(icount)) deallocate(icount)
allocate(icount(ndims))
return
end
\ No newline at end of file
return
end
SUBROUTINE CALDATE(JULDATE,YYYYMMDD,HHMISS)
!c i o o
!!* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
!**********************************************************************
! Copyright 2016 *
! Andreas Stohl, Massimo Cassiani, Petra Seibert, A. Frank, *
! Gerhard Wotawa, Caroline Forster, Sabine Eckhardt, John Burkhart, *
! Harald Sodemann *
! *
! This file is part of FLEXPART-NorESM *
! *
! FLEXPART-NorESM is free software: you can redistribute it *
! and/or modify *
! it under the terms of the GNU General Public License as published by*
! the Free Software Foundation, either version 3 of the License, or *
! (at your option) any later version. *
! *
! FLEXPART-NorESM is distributed in the hope that it will be useful, *
! but WITHOUT ANY WARRANTY; without even the implied warranty of *
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
! GNU General Public License for more details. *
! *
! You should have received a copy of the GNU General Public License *
! along with FLEXPART-NorESM. *
! If not, see <http://www.gnu.org/licenses/>. *
!**********************************************************************
SUBROUTINE CALDATE(JULDATE,YYYYMMDD,HHMISS)
!c i o o
!
!* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
!* *
!* Calculates a pseudo-Gregorian date (from year zero ) using the *
!* juldate varaiable *
!* Calculates a pseudo-Gregorian date (from year zero) using the *
!* juldate varaiable *
!* juldate actually contains days from arbitrary origin date (yearorigin) *
!* using no leap calendar *
!* Author: *
!* M. Cassiani 2016 *
!* *
!* *
! *
!* *
! Variables: *
!* *
! Variables: *
!* DD Day *
!* HH Hour *
!* HHMISS Hour, Minute, Second *
......@@ -34,25 +65,17 @@
DOUBLE PRECISION JULDATE
INTEGER daysannozero
!if (yearorigin.lt.0) then
!daysannozero=abs(yearorigin)*365 !year -1, month 1, day1 is 365 days to begin of year 1
!else
!daysannozero=abs(yearorigin-1)*365 !year 1, month 1, day1 is 0 days to begin of year 1
!end if
YYYY=INT(JULDATE)/365 !-yearorigin
YYYY=INT(JULDATE)/365
JULDAY=INT(JULDATE)
!DAYS=INT(JULDATE)-daysannozero-YYYY*365
DAYS=JULDAY-YYYY*365
if (DAYS.gt.59) then
!MM=(((DAYS-59)*5)-2)/153
MM=int((((DAYS-0.1-59.)*5.)-2.)/153.)
MM=int((((DAYS-0.1-59.)*5.)-2.)/153.)
ddpm=((153*MM)+2)/5
DD=DAYS-ddpm-59
else
!MM=(((DAYS+306)*5)-2)/153
MM=int((((DAYS-0.1+306.)*5.)-2.)/153.)
ddpm=((153*MM)+2)/5
DD=DAYS+306-ddpm
......
subroutine check_variable(varname,fnamenc,maxdim,typetocheck, &
id_var,ndims,id_dim,ierr,ncid)
implicit none
include 'netcdf.inc'
character*160 :: varname,vartype
integer :: maxdim
integer :: id_var,itype_var,id_dim(maxdim),sizetype
integer :: typetocheck
integer :: natts_tot, ncid, ndims
integer :: ierr,iret !error code message
character*110 :: fnamenc
!c--------- check --------------------------------
!**********************************************************************
! Copyright 2016 *
! Andreas Stohl, Massimo Cassiani, Petra Seibert, A. Frank, *
! Gerhard Wotawa, Caroline Forster, Sabine Eckhardt, John Burkhart, *
! Harald Sodemann *
! *
! This file is part of FLEXPART-NorESM *
! *