<div dir="ltr">Hi Dave,<div><br></div><div style>I was unaware of this &quot;:=&quot; issue. I simply thought &quot;fout&quot; was a file handle. After your recommended changes I still got the error. I even passed fout to the function and returned 0 to a dummy variable but I still got the same error. In order to speed up the script I moved the fout-&gt;time(itime) = (/f-&gt;time(itime)/)/60.0 into the loop. The speeds things up tremendously when the time dimension is set to unlimited. But there is something going on that I cannot grasp about NCL.</div>
<div style><br></div><div style><div>print(&quot;Regridding the variables...&quot;)                                                                                                                          </div><div>do itime = 0, 3;endtime                                                                                                                                       </div>
<div>  print(&quot;Processing time step: &quot;+itime)                                                                                                                       </div><div>  fout-&gt;time(itime) = (/f-&gt;time(itime)/)/60.0 ; change the time to hours                                                                                      </div>
<div>  do n = 0, nsize ; loop over the different variables                                                                                                         </div><div>   print(&quot;Processing variable:-&gt; &quot;+name(n)+&quot; mapping to:-&gt;&quot;+Sname(n))                                                                                         </div>
<div>   if(name(n).eq.&quot;var26&quot; .or.\                                                                                                                                </div><div>      name(n).eq.&quot;var142&quot; .or.\                                                                                                                               </div>
<div>      name(n).eq.&quot;var143&quot; .or.\                                                                                                                               </div><div>      name(n).eq.&quot;var178&quot; .or.\                                                                                                                               </div>
<div>      name(n).eq.&quot;var179&quot; .or.\                                                                                                                               </div><div>      name(n).eq.&quot;var184&quot; .or.\                                                                                                                               </div>
<div>      name(n).eq.&quot;var245&quot; .or.\                                                                                                                               </div><div>      name(n).eq.&quot;var246&quot; .or.\                                                                                                                               </div>
<div>      name(n).eq.&quot;var247&quot; .or.\                                                                                                                               </div><div>      name(n).eq.&quot;var248&quot; .or.\                                                                                                                               </div>
<div>      name(n).eq.&quot;var249&quot; .or.\                                                                                                                               </div><div>      name(n).eq.&quot;var251&quot; .or.\                                                                                                                               </div>
<div>      name(n).eq.&quot;var252&quot; .or.\                                                                                                                               </div><div>      name(n).eq.&quot;var253&quot;) then                                                                                                                               </div>
<div>      fout := Pro2D(f,fout,Sname(n),name(n),itime,LAT1x1,LON1x1,LAT2x2,LON2x2,n)                                                                              </div><div>    end if                                                                                                                                                    </div>
<div>                                                                                                                                                              </div><div>   if(name(n).eq.&quot;var21&quot; .or.\                                                                                                                                </div>
<div>      name(n).eq.&quot;var22&quot; .or.\                                                                                                                                </div><div>      name(n).eq.&quot;var23&quot; .or.\                                                                                                                                </div>
<div>      name(n).eq.&quot;var24&quot; .or.\                                                                                                                                </div><div>      name(n).eq.&quot;var25&quot; .or.\                                                                                                                                </div>
<div>      name(n).eq.&quot;var223&quot;) then                                                                                                                               </div><div>      do level = 0, nlevs                                                                                                                                     </div>
<div>        fout := Pro3D(f,fout,Sname(n),name(n),itime,level,f-&gt;lev_2(level),LAT1x1,LON1x1,LAT2x2,LON2x2,n)                                                      </div><div>      end do                                                                                                                                                  </div>
<div>    end if                                                                                                                                                    </div><div> end do                                                                                                                                                       </div>
<div> ;print(&quot;Time in file: &quot;+fout-&gt;time(itime))  </div><div style>end do</div><div style><br></div><div>@a7 ncl_codes]$ ncl echam_regrid.ncl</div><div> Copyright (C) 1995-2013 - All Rights Reserved</div><div>
 University Corporation for Atmospheric Research</div><div> NCAR Command Language Version 6.1.2</div><div> The use of this software is governed by a License Agreement.</div><div> See <a href="http://www.ncl.ucar.edu/">http://www.ncl.ucar.edu/</a> for more details.</div>
<div>(0)     Names in nc file: var26</div><div>(1)     Names in nc file: var142</div><div>(2)     Names in nc file: var143</div><div>(3)     Names in nc file: var178</div><div>(4)     Names in nc file: var179</div><div>(5)     Names in nc file: var184</div>
<div>(6)     Names in nc file: var245</div><div>(7)     Names in nc file: var246</div><div>(8)     Names in nc file: var247</div><div>(9)     Names in nc file: var248</div><div>(10)    Names in nc file: var249</div><div>(11)    Names in nc file: var251</div>
<div>(12)    Names in nc file: var252</div><div>(13)    Names in nc file: var253</div><div>(14)    Names in nc file: var21</div><div>(15)    Names in nc file: var22</div><div>(16)    Names in nc file: var23</div><div>(17)    Names in nc file: var24</div>
<div>(18)    Names in nc file: var25</div><div>(19)    Names in nc file: var223</div><div>(20)    Names in nc file: var243</div><div>(21)    Names in nc file: var244</div><div>(0)     Create a large file to hold the data</div>
<div>(0)     Regridding the variables...</div><div>(0)     Processing time step: 0</div><div>(0)     Processing variable:-&gt; var26 mapping to:-&gt;SP</div><div>(0)     Processing variable:-&gt; var142 mapping to:-&gt;LSP</div>
<div>(0)     Processing variable:-&gt; var143 mapping to:-&gt;CP</div><div>(0)     Processing variable:-&gt; var178 mapping to:-&gt;TSIR</div><div>(0)     Processing variable:-&gt; var179 mapping to:-&gt;TTR</div><div>(0)     Processing variable:-&gt; var184 mapping to:-&gt;SI</div>
<div>(0)     Processing variable:-&gt; var245 mapping to:-&gt;sunlit_ISCCP</div><div>(0)     Processing variable:-&gt; var246 mapping to:-&gt;TCC_ISCCP</div><div>(0)     Processing variable:-&gt; var247 mapping to:-&gt;CTP_ISCCP</div>
<div>(0)     Processing variable:-&gt; var248 mapping to:-&gt;CALB_ISCCP</div><div>(0)     Processing variable:-&gt; var249 mapping to:-&gt;TAU_ISCCP</div><div>(0)     Processing variable:-&gt; var251 mapping to:-&gt;DCFLAG</div>
<div>(0)     Processing variable:-&gt; var252 mapping to:-&gt;SCFLAG</div><div>(0)     Processing variable:-&gt; var253 mapping to:-&gt;MCFLAG</div><div>(0)     Calculate the ALBEDO...</div><div>(0)     Processing variable:-&gt; var21 mapping to:-&gt;R</div>
<div>(0)     Processing variable:-&gt; var22 mapping to:-&gt;Q</div><div>(0)     Processing variable:-&gt; var23 mapping to:-&gt;CLWC</div><div>(0)     Processing variable:-&gt; var24 mapping to:-&gt;CIWC</div><div>(0)     Processing variable:-&gt; var25 mapping to:-&gt;T</div>
<div>(0)     Processing variable:-&gt; var223 mapping to:-&gt;CC</div><div>(0)     Processing variable:-&gt; var243 mapping to:-&gt;CC_ISCCP_3D</div><div>(0)     Processing variable:-&gt; var244 mapping to:-&gt;TAU_ISCCP_3D</div>
<div>(0)     Processing time step: 1</div><div>(0)     Processing variable:-&gt; var26 mapping to:-&gt;SP</div><div>(0)     Processing variable:-&gt; var142 mapping to:-&gt;LSP</div><div>(0)     Processing variable:-&gt; var143 mapping to:-&gt;CP</div>
<div>(0)     Processing variable:-&gt; var178 mapping to:-&gt;TSIR</div><div>(0)     Processing variable:-&gt; var179 mapping to:-&gt;TTR</div><div>(0)     Processing variable:-&gt; var184 mapping to:-&gt;SI</div><div>(0)     Processing variable:-&gt; var245 mapping to:-&gt;sunlit_ISCCP</div>
<div>(0)     Processing variable:-&gt; var246 mapping to:-&gt;TCC_ISCCP</div><div>(0)     Processing variable:-&gt; var247 mapping to:-&gt;CTP_ISCCP</div><div>(0)     Processing variable:-&gt; var248 mapping to:-&gt;CALB_ISCCP</div>
<div>(0)     Processing variable:-&gt; var249 mapping to:-&gt;TAU_ISCCP</div><div>(0)     Processing variable:-&gt; var251 mapping to:-&gt;DCFLAG</div><div>(0)     Processing variable:-&gt; var252 mapping to:-&gt;SCFLAG</div>
<div>(0)     Processing variable:-&gt; var253 mapping to:-&gt;MCFLAG</div><div>fatal:Subscript out of range, error in subscript #0</div><div>fatal:Subscript out of range, error in subscript #0</div><div>fatal:Subscript out of range, error in subscript #0</div>
<div>fatal:Subscript out of range, error in subscript #0</div><div>fatal:Subscript out of range, error in subscript #0</div><div>fatal:Subscript out of range, error in subscript #0</div><div>(0)     Calculate the ALBEDO...</div>
<div>fatal:Subscript out of range, error in subscript #0</div><div>fatal:Subscript out of range, error in subscript #0</div><div>fatal:Subscript out of range, error in subscript #0</div><div>fatal:Subscript out of range, error in subscript #0</div>
<div>fatal:Subscript out of range, error in subscript #0</div><div style> </div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Oct 22, 2013 at 8:50 PM, David Brown <span dir="ltr">&lt;<a href="mailto:dbrown@ucar.edu" target="_blank">dbrown@ucar.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Marston,<div>You are using &#39;fout&#39; as the variable for both the 2D and the 3D variables. Once the variable is initialized, any attempt to assign different dimensions or sizes will cause an error.</div>
<div>The fix, most likely, is either to call</div><div>delete(fout) </div><div>at the end of each loop iteration, or (recommended) to use the new &#39;reassignment&#39; operator &#39;:=&#39;, e.g.:</div><div><br></div><div>
fout : = Pro2D(f,fout,Sname(n),name(n),itime,LAT1x1,LON1x1,LAT2x2,LON2x2,n)</div><div><br></div><div>and  later</div><div><br></div><div>fout := Pro3D(f,fout,Sname(n),name(n),itime,level,f-&gt;lev_2(level),LAT1x1,LON1x1,LAT2x2,LON2x2,n)</div>
<div><br></div><div> -dave</div><div><br></div><div><br><div><div><div class="h5"><div>On Oct 22, 2013, at 12:09 PM, Marston Johnston &lt;<a href="mailto:shejo284@gmail.com" target="_blank">shejo284@gmail.com</a>&gt; wrote:</div>
<br></div></div><blockquote type="cite"><div><div class="h5"><div dir="ltr">Hi all,<div><br></div><div>I know this error: fatal:Subscript out of range, error in subscript #0, seems like a simple enough error message to understand but I cannot seem to find the cause of the problem. I&#39;m writing data to a file and after some variables are written, I read the data from the newly written file and create a new variable, then I write the new variable to the outfile. It is when I write this new variable that I get this error which frankly boggles my mind. The error occurs on the 2nd time step. I would love some assistance in understanding and solving this error.</div>

<div><br></div><div>I have attached the script and below is a copy of the output for two time steps:</div><div><br></div><div><div>%@a7 ncl_codes]$ ncl echam_regrid.ncl</div><div> Copyright (C) 1995-2013 - All Rights Reserved</div>

<div> University Corporation for Atmospheric Research</div><div> NCAR Command Language Version 6.1.2</div><div> The use of this software is governed by a License Agreement.</div><div> See <a href="http://www.ncl.ucar.edu/" target="_blank">http://www.ncl.ucar.edu/</a> for more details.</div>

<div>(0)     Names in nc file: var26</div><div>(1)     Names in nc file: var142</div><div>(2)     Names in nc file: var143</div><div>(3)     Names in nc file: var178</div><div>(4)     Names in nc file: var179</div><div>(5)     Names in nc file: var184</div>

<div>(6)     Names in nc file: var245</div><div>(7)     Names in nc file: var246</div><div>(8)     Names in nc file: var247</div><div>(9)     Names in nc file: var248</div><div>(10)    Names in nc file: var249</div><div>
(11)    Names in nc file: var251</div>
<div>(12)    Names in nc file: var252</div><div>(13)    Names in nc file: var253</div><div>(14)    Names in nc file: var21</div><div>(15)    Names in nc file: var22</div><div>(16)    Names in nc file: var23</div><div>(17)    Names in nc file: var24</div>

<div>(18)    Names in nc file: var25</div><div>(19)    Names in nc file: var223</div><div>(20)    Names in nc file: var243</div><div>(21)    Names in nc file: var244</div><div>(0)     Create a large file to hold the data</div>

<div>(0)     Regridding the variables...</div><div>(0)     Processing time step: 0</div><div>(0)     Processing variable:-&gt; var26 mapping to:-&gt;SP</div><div>(0)     Processing variable:-&gt; var142 mapping to:-&gt;LSP</div>

<div>(0)     Processing variable:-&gt; var143 mapping to:-&gt;CP</div><div>(0)     Processing variable:-&gt; var178 mapping to:-&gt;TSIR</div><div>(0)     Processing variable:-&gt; var179 mapping to:-&gt;TTR</div><div>(0)     Processing variable:-&gt; var184 mapping to:-&gt;SI</div>

<div>(0)     Processing variable:-&gt; var245 mapping to:-&gt;sunlit_ISCCP</div><div>(0)     Processing variable:-&gt; var246 mapping to:-&gt;TCC_ISCCP</div><div>(0)     Processing variable:-&gt; var247 mapping to:-&gt;CTP_ISCCP</div>

<div>(0)     Processing variable:-&gt; var248 mapping to:-&gt;CALB_ISCCP</div><div>(0)     Processing variable:-&gt; var249 mapping to:-&gt;TAU_ISCCP</div></div><div><div>(0)     Processing variable:-&gt; var251 mapping to:-&gt;DCFLAG</div>

<div>(0)     Processing variable:-&gt; var252 mapping to:-&gt;SCFLAG</div><div>(0)     Processing variable:-&gt; var253 mapping to:-&gt;MCFLAG</div><div>(0)     Calculate the ALBEDO...</div><div>(0)     Processing variable:-&gt; var21 mapping to:-&gt;R</div>

<div>(0)     Processing variable:-&gt; var22 mapping to:-&gt;Q</div><div>(0)     Processing variable:-&gt; var23 mapping to:-&gt;CLWC</div><div>(0)     Processing variable:-&gt; var24 mapping to:-&gt;CIWC</div><div>(0)     Processing variable:-&gt; var25 mapping to:-&gt;T</div>

<div><br></div><div>(0)     Processing variable:-&gt; var223 mapping to:-&gt;CC</div><div>(0)     Processing variable:-&gt; var243 mapping to:-&gt;CC_ISCCP_3D</div><div>(0)     Processing variable:-&gt; var244 mapping to:-&gt;TAU_ISCCP_3D</div>

<div>(0)     Processing time step: 1</div><div>(0)     Processing variable:-&gt; var26 mapping to:-&gt;SP</div><div>(0)     Processing variable:-&gt; var142 mapping to:-&gt;LSP</div><div>(0)     Processing variable:-&gt; var143 mapping to:-&gt;CP</div>

<div>(0)     Processing variable:-&gt; var178 mapping to:-&gt;TSIR</div><div>(0)     Processing variable:-&gt; var179 mapping to:-&gt;TTR</div><div>(0)     Processing variable:-&gt; var184 mapping to:-&gt;SI</div><div>(0)     Processing variable:-&gt; var245 mapping to:-&gt;sunlit_ISCCP</div>

<div>(0)     Processing variable:-&gt; var246 mapping to:-&gt;TCC_ISCCP</div><div>(0)     Processing variable:-&gt; var247 mapping to:-&gt;CTP_ISCCP</div><div>(0)     Processing variable:-&gt; var248 mapping to:-&gt;CALB_ISCCP</div>

<div>(0)     Processing variable:-&gt; var249 mapping to:-&gt;TAU_ISCCP</div><div>(0)     Processing variable:-&gt; var251 mapping to:-&gt;DCFLAG</div><div>(0)     Processing variable:-&gt; var252 mapping to:-&gt;SCFLAG</div>

<div>(0)     Processing variable:-&gt; var253 mapping to:-&gt;MCFLAG</div><div>fatal:Subscript out of range, error in subscript #0</div><div>fatal:Subscript out of range, error in subscript #0</div><div>fatal:Subscript out of range, error in subscript #0</div>

<div>fatal:Subscript out of range, error in subscript #0</div><div>fatal:Subscript out of range, error in subscript #0</div><div>fatal:Subscript out of range, error in subscript #0</div><div><br></div><div>The input file is very large but if you have room on the NCL server I could upload it.</div>

<div><br></div><div>Thanks in advance,</div></div><div>/Marston</div></div>
</div></div><span>&lt;echam_regrid.ncl&gt;</span>_______________________________________________<br>ncl-talk mailing list<br>List instructions, subscriber options, unsubscribe:<br><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div><br></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Only the fruitful thing is true!
</div>