Index: src/gridcheck_gfs.f90
===================================================================
--- src/gridcheck_gfs.f90	(revision a756649aa5143665ab2654ea5dd5e713950bb1a2)
+++ src/gridcheck_gfs.f90	(revision 467460af7de11cc1002100a8e56de8b8108cd235)
@@ -1,22 +1,4 @@
-!**********************************************************************
-! 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   *
-!                                                                     *
-! This file is part of FLEXPART.                                      *
-!                                                                     *
-! FLEXPART 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,         *
-! 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/>.   *
-!**********************************************************************
+! SPDX-FileCopyrightText: FLEXPART 1998-2019, see flexpart_license.txt
+! SPDX-License-Identifier: GPL-3.0-or-later
 
 subroutine gridcheck_gfs
@@ -93,10 +75,10 @@
   real :: sizesouth,sizenorth,xauxa,pint
   real :: akm_usort(nwzmax)
-  real,parameter :: eps=0.0001
+  real,parameter :: eps=spacing(2.0_4*360.0_4) 
 
   ! NCEP GFS
   real :: pres(nwzmax), help
 
-  integer :: i179,i180,i181
+  integer :: i180
 
   ! VARIABLES AND ARRAYS NEEDED FOR GRIB DECODING
@@ -242,7 +224,7 @@
   nxfield=isec2(2)
   ny=isec2(3)
-  if((abs(xaux1).lt.eps).and.(xaux2.ge.359)) then ! NCEP DATA FROM 0 TO
-    xaux1=-179.0                             ! 359 DEG EAST ->
-    xaux2=-179.0+360.-360./real(nxfield)    ! TRANSFORMED TO -179
+  if((abs(xaux1).lt.eps).and.(xaux2.ge.359.)) then ! NCEP DATA FROM 0 TO
+    xaux1=-180.0                             ! 359 DEG EAST ->
+    xaux2=-180.0+360.-360./real(nxfield)    ! TRANSFORMED TO -179
   endif                                      ! TO 180 DEG EAST
   if (xaux1.gt.180) xaux1=xaux1-360.0
@@ -323,11 +305,5 @@
 
 
-  i179=nint(179./dx)
-  if (dx.lt.0.7) then
-    i180=nint(180./dx)+1    ! 0.5 deg data
-  else
-    i180=nint(179./dx)+1    ! 1 deg data
-  endif
-  i181=i180+1
+  i180=nint(180./dx)    ! 0.5 deg data
 
 
@@ -339,10 +315,10 @@
       do ix=0,nxfield-1
         help=zsec4(nxfield*(ny-jy-1)+ix+1)
-        if(ix.le.i180) then
-          oro(i179+ix,jy)=help
-          excessoro(i179+ix,jy)=0.0 ! ISOBARIC SURFACES: SUBGRID TERRAIN DISREGARDED
+        if(ix.lt.i180) then
+          oro(i180+ix,jy)=help
+          excessoro(i180+ix,jy)=0.0 ! ISOBARIC SURFACES: SUBGRID TERRAIN DISREGARDED
         else
-          oro(ix-i181,jy)=help
-          excessoro(ix-i181,jy)=0.0 ! ISOBARIC SURFACES: SUBGRID TERRAIN DISREGARDED
+          oro(ix-i180,jy)=help
+          excessoro(ix-i180,jy)=0.0 ! ISOBARIC SURFACES: SUBGRID TERRAIN DISREGARDED
         endif
       end do
@@ -357,8 +333,8 @@
       do ix=0,nxfield-1
         help=zsec4(nxfield*(ny-jy-1)+ix+1)
-        if(ix.le.i180) then
-          lsm(i179+ix,jy)=help
+        if(ix.lt.i180) then
+          lsm(i180+ix,jy)=help
         else
-          lsm(ix-i181,jy)=help
+          lsm(ix-i180,jy)=help
         endif
       end do
@@ -431,5 +407,5 @@
     write(*,*)
     write(*,*)
-    write(*,'(a,2i7)') 'Vertical levels in NCEP data: ', &
+  write(*,'(a,2i7)') '# of vertical levels in NCEP data: ', &
          nuvz,nwz
     write(*,*)
