{"id":21,"date":"2011-04-19T10:00:00","date_gmt":"2011-04-19T10:00:00","guid":{"rendered":"http:\/\/mattdturner.com\/wordpress\/?p=21"},"modified":"2011-04-26T11:39:54","modified_gmt":"2011-04-26T17:39:54","slug":"how-to-fix-output-conversion-error","status":"publish","type":"post","link":"http:\/\/mattdturner.com\/wordpress\/2011\/04\/how-to-fix-output-conversion-error\/","title":{"rendered":"How to Fix &#8220;Output Conversion Error&#8221;"},"content":{"rendered":"<p>As part of my research for my Ph.D. I am on a team that is currently developing an adjoint of the EPA&#8217;s CMAQ air quality model. \u00a0In 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.<\/p>\n<p>Running the model would result in many occurances of the following error:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">forrtl: error (63): output conversion error, unit -5, file Internal Formatted Write\r\nImage              PC                Routine            Line        Source\r\nADJOINT_FWD       \u00a000000000009B34BD  Unknown            Unknown     Unknown\r\nADJOINT_FWD        00000000009B1FC5  Unknown            Unknown     Unknown\r\nADJOINT_FWD        0000000000969210  Unknown            Unknown     Unknown\r\nADJOINT_FWD        000000000092AADF  Unknown            Unknown     Unknown\r\nADJOINT_FWD        000000000092A312  Unknown            Unknown     Unknown\r\nADJOINT_FWD        000000000095305A  Unknown            Unknown     Unknown\r\nADJOINT_FWD        00000000005D9F94  ckdesc3_             138       ckdesc3.f\r\nADJOINT_FWD        00000000005A9FD1  open3_               216       open3.F\r\nADJOINT_FWD        000000000047B395  chk_files_impl_mp    170      CHK_FILES_IMPL.F\r\nADJOINT_FWD        0000000000485060  chk_files1_mp_chk    347       CHK_FILES.F\r\nADJOINT_FWD        00000000005666CB  vdiff_               369       vdiffacm2.F\r\nADJOINT_FWD        0000000000496B7E  sciproc_             228       sciproc.F\r\nADJOINT_FWD        000000000048DDB5  MAIN__               205       driver_fwd.F\r\nADJOINT_FWD        0000000000404A1C  Unknown            Unknown     Unknown\r\nlibc.so.6          0000003FE9E1D994  Unknown            Unknown     Unknown\r\nADJOINT_FWD        0000000000404929  Unknown            Unknown     Unknown\r\n\r\n     &gt;&gt;&gt; WARNING in subroutine CRTFIL3 &lt;&lt;&lt;\r\n     Error creating netCDF variable for file ADJ_VDIFF_CHK\r\n     Illegal data type    0\r\n\r\n     *** ERROR ABORT in subroutine CHK_FILE_CREATE_\r\n     Could not open ADJ_VDIFF_CHK file\r\n     Date and time  13:00:00  July 22, 2001   (2001203:130000)\r\n\r\n<\/pre>\n<p>I spent a lot of time searching online, however I was unable to find a solution for my problem. \u00a0After days of debugging, I finally found the source of the problem.<\/p>\n<p><!--more--><\/p>\n<p>The &#8220;output conversion error&#8221; comes from a <code>WRITE<\/code> command that uses an incorrect format for the number to print. \u00a0It 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.<\/p>\n<p>The problematic section of the code is shown below:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">      DO  U = 2, NVARS3D\r\n      DO  V = 1, U-1\r\n         IF( VNAME3D( U ) .EQ. VNAME3D( V ) ) THEN\r\n\r\n            WRITE( MESG, 94030 )\r\n     &amp;         'Variable name VNAME3D(', U, ') = &quot;' \/\/\r\n     &amp;          VNAME3D( U )( 1:TRIMLEN( VNAME3D( U ) ) ) \/\/\r\n     &amp;         '&quot; duplicates VNAME3D(', V, ') = &quot;' \/\/\r\n     &amp;          VNAME3D( V )( 1:TRIMLEN( VNAME3D( V ) ) ) \/\/\r\n     &amp;         '&quot; in file &quot;' \/\/ FNAME( 1:TRIMLEN( FNAME ) ) \/\/ '&quot;'\r\n\r\n            CALL M3MSG2( MESG )            EFLAG = .TRUE.\r\n\r\n         END IF\r\n\r\n      END DO      END DO\r\n\r\n94030   FORMAT( 4 ( A, I2, :, 2X ) )<\/pre>\n<div>\n<p>The reason for the error was that the variable <code>U<\/code> had a max value of 125 in our case, while the format descriptor only allowed for a 2 digit integer in the <code>WRITE<\/code> statement.  Changing <code>I2<\/code> to <code>I3<\/code> fixed the problem.<\/p>\n<p>This was actually a bug in the IOAPI release, and has subsequently been resolved.<\/p>\n<\/div>\n<div class=\"zemanta-pixie\" style=\"margin-top: 10px; height: 15px;\"><a class=\"zemanta-pixie-a\" title=\"Enhanced by Zemanta\" href=\"http:\/\/www.zemanta.com\/\"><img decoding=\"async\" class=\"zemanta-pixie-img\" style=\"border: none; float: right;\" src=\"http:\/\/img.zemanta.com\/zemified_e.png?x-id=d7d56145-2a7e-477c-98b3-df5be8bf427f\" alt=\"Enhanced by Zemanta\" \/><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>As part of my research for my Ph.D. I am on a team that is currently developing an adjoint of the EPA&#8217;s CMAQ air quality model. \u00a0In 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3,32],"tags":[30,31,28,29,23],"class_list":["post-21","post","type-post","status-publish","format-standard","hentry","category-command-line","category-debugging","tag-command-line-2","tag-debug","tag-fortran","tag-ifort","tag-source-code","no-thumb"],"_links":{"self":[{"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/posts\/21"}],"collection":[{"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/comments?post=21"}],"version-history":[{"count":4,"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/posts\/21\/revisions"}],"predecessor-version":[{"id":54,"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/posts\/21\/revisions\/54"}],"wp:attachment":[{"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/media?parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/categories?post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/tags?post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}