geoschem / geos-chem

GEOS-Chem "Science Codebase" repository. Contains GEOS-Chem science routines, run directory generation scripts, and interface code. This repository is used as a submodule within the GCClassic and GCHP wrappers, as well as in other modeling contexts (external ESMs).
http://geos-chem.org
Other
164 stars 156 forks source link

[BUG/ISSUE] Add missing OPEN statement in UCX routine SFCMR_READ #115

Closed yantosca closed 4 years ago

yantosca commented 4 years ago

Describe the bug:

While testing GCHP, we discovered that the run died with this error:

GEOS-CHEM ERROR: Beyond max. number of lines: /n/holylfs/EXTERNAL_REPOS/GEOS-CHEM/gcgr/ExtData/CHEM_INPUTS/UCX_201403/Montreal/CFC11_boundary
STOP at UCX_MOD: SFCMR_READ

We have traced this to a missing OPEN statement in routine SFCMR_READ (which only gets used when UCXNETCDF=FALSE, as is the case for GCHP). This was causing GEOS-Chem to try to read data from a file called fort.14 instead of the actual file.

Solution:

Add this OPEN statement in the code below:

      ! If no fixed MR is given, read MR and years from ASCII file
      ELSE

         ! Construct file name
         FILENAME = TRIM(MONTREAL_FILE_ROOT)//TRIM(iName)//'_boundary'

         IF ( doPrint ) THEN
            WRITE(DBGMSG,'(a,a,a,a)') ' ### UCX: Reading ',
     &           TRIM(iNAME), ' from ', TRIM( FILENAME )
            CALL DEBUG_MSG( TRIM(DBGMSG) )
         ENDIF      

         ! Get a free LUN
         IU_FILE = findFreeLUN()      

         ! Initialize values
         IOS = 1
         NX  = 0  ! number of values

         ! Print the name of the file being read to stdout (bmy, 10/23/19)
         IF ( am_I_Root ) THEN
            WRITE( 6, 300 ) TRIM( FileName )
 300        FORMAT( 'UCX (SFCMR_READ): Reading ', a )
         ENDIF

         !#### ADDED THIS OPEN STATEMENT ######
         ! Open the file for reading
         OPEN(IU_FILE, FILE=TRIM( FILENAME ), 
     &        STATUS='OLD', FORM='FORMATTED')

         ! First line not important
         READ(IU_FILE, '(a)', IOSTAT=IOS) DUMMY
         IF ( IOS /= 0 ) THEN
            WRITE(6,*) 'UCX: READ ERROR L1 IN ', TRIM(FILENAME)
             CALL IOERROR( IOS, IU_FILE, 'UCX_MOD:SFCMR_READ')
         ENDIF

This will go into GEOS-Chem 12.6.1.

yantosca commented 4 years ago

Pushed commit https://github.com/geoschem/geos-chem/commit/ab15ea12b1ebc11c2bde2e16c5df2e6bd7467e7 which now resolves this issue. This will go live in 12.6.1.

yantosca commented 4 years ago

Also note: the OPEN statement in question was inadvertently deleted in this commit: https://github.com/geoschem/geos-chem/commit/62743d4dd9d325ec6a80841f29b889bdc1caba95, which was committed to dev/12.6.1. The OPEN statement has now been restored and will be included again in GEOS-Chem 12.6.1.

lizziel commented 4 years ago

Just to be clear, this bug does not impact master (12.6.0) or prior versions.

yantosca commented 4 years ago

Now included in GC 12.6.1, released on 28 Oct 2019.