My blog has moved!

You should be automatically redirected in 6 seconds. If not, visit
http://www.mattdturner.com/wordpress
and update your bookmarks.

AdSense

Pages

Tuesday, April 19, 2011

How to Fix "Output Conversion Error"

As part of my research for my Ph.D. I am on a team that is currently developing an adjoint of the EPA's CMAQ air quality model.  In the process of integrating all parts of the model into the full adjoint model, I ran into an error that was rather difficult to resolve.

Running the model would result in many occurances of the following error:

forrtl: error (63): output conversion error, unit -5, file Internal Formatted Write
Image              PC                Routine            Line        Source             
ADJOINT_FWD        00000000009B34BD  Unknown               Unknown  Unknown
ADJOINT_FWD        00000000009B1FC5  Unknown               Unknown  Unknown
ADJOINT_FWD        0000000000969210  Unknown               Unknown  Unknown
ADJOINT_FWD        000000000092AADF  Unknown               Unknown  Unknown
ADJOINT_FWD        000000000092A312  Unknown               Unknown  Unknown
ADJOINT_FWD        000000000095305A  Unknown               Unknown  Unknown
ADJOINT_FWD        00000000005D9F94  ckdesc3_                  138  ckdesc3.f
ADJOINT_FWD        00000000005A9FD1  open3_                    216  open3.F
ADJOINT_FWD        000000000047B395  chk_files_impl_mp         170  CHK_FILES_IMPL.F
ADJOINT_FWD        0000000000485060  chk_files1_mp_chk         347  CHK_FILES.F
ADJOINT_FWD        00000000005666CB  vdiff_                    369  vdiffacm2.F
ADJOINT_FWD        0000000000496B7E  sciproc_                  228  sciproc.F
ADJOINT_FWD        000000000048DDB5  MAIN__                    205  driver_fwd.F
ADJOINT_FWD        0000000000404A1C  Unknown               Unknown  Unknown
libc.so.6          0000003FE9E1D994  Unknown               Unknown  Unknown
ADJOINT_FWD        0000000000404929  Unknown               Unknown  Unknown


     >>> WARNING in subroutine CRTFIL3 <<<
     Error creating netCDF variable for file ADJ_VDIFF_CHK   
     Illegal data type    0

      
     *** ERROR ABORT in subroutine CHK_FILE_CREATE_
     Could not open ADJ_VDIFF_CHK file
     Date and time  13:00:00  July 22, 2001   (2001203:130000)


I spent a lot of time searching online, however I was unable to find a solution for my problem.  After days of debugging, I finally found the source of the problem.

The "output conversion error" comes from a WRITE command that uses an incorrect format for the number to print.  It is often caused by numbers being bigger than expected. In the case of CMAQ adjoint, the problem was within the ckdesc.f file for ioapi.

The problematic section of the code is shown below:
      DO  U = 2, NVARS3D
      DO  V = 1, U-1
         IF( VNAME3D( U ) .EQ. VNAME3D( V ) ) THEN

            WRITE( MESG, 94030 )
     &         'Variable name VNAME3D(', U, ') = "' //
     &          VNAME3D( U )( 1:TRIMLEN( VNAME3D( U ) ) ) //
     &         '" duplicates VNAME3D(', V, ') = "' //
     &          VNAME3D( V )( 1:TRIMLEN( VNAME3D( V ) ) ) //
     &         '" in file "' // FNAME( 1:TRIMLEN( FNAME ) ) // '"'

            CALL M3MSG2( MESG )
            EFLAG = .TRUE.

         END IF

      END DO
      END DO

94030   FORMAT( 4 ( A, I2, :, 2X ) )

The reason for the error was that the variable U had a max value of 125 in our case, while the format descriptor only allowed for a 2 digit integer in the WRITE statement. Changing I2 to I3 fixed the problem.

This was actually a bug in the IOAPI release, and has subsequently been resolved.

0 comments:

Post a Comment