<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection">
<div dir="auto"><span style="font-family:Menlo">Hi Jeff,</span><br /></div>
<blockquote style="border-left-color: rgb(26, 188, 156); margin: 5px; padding-left: 10px; border-left-width: thin; border-left-style: solid;"><span style="font-family:Menlo"> </span> MITgcm requires big endian files,</blockquote>
<div dir="auto"><br />
<span style="font-family:Menlo">I’ve always run the MITgcm with native little-endian with no difficulty.  Are there any clusters that are big-endian these days?  I’ve been using MITgcm for 12 years, and probably on 12 different clusters, and they have all been little-endian.  I’m not clear why the big-endian convention is still so strongly favoured.  </span><br />
<br />
<span style="font-family:Menlo">Cheers   Jody</span></div>
</div>
<div name="messageSignatureSection"><br />
<div class="matchFont">—
<div dir="auto">Jody Klymak</div>
<div dir="auto">http://ocean-physics.seos.uvic.ca/~jklymak/</div>
<div dir="auto"><br /></div>
</div>
</div>
<div name="messageReplySection">On Apr 1, 2021, 13:59 -0700, Jeffery R Scott <jscott@mit.edu>, wrote:<br />
<blockquote type="cite" style="border-left-color: grey; border-left-width: thin; border-left-style: solid; margin: 5px 5px;padding-left: 10px;">Hi Jeremy,
<div class=""><br class="" /></div>
<div class="">As Jan responded, MITgcm requires big endian files, which the byteswap statement accomplishes.</div>
<div class="">(the other way to do this : data.astype('>f4').tofile('data.bin’) forces python to write out the field in big endian, as mentioned in manual section 3.9)</div>
<div class=""><br class="" /></div>
<div class="">When you write out a file in big endian, you also need to tell python to read it back in big endian format:</div>
<div class=""><br class="" /></div>
<div class="">
<div class="">
<div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255);" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">tau_2_1 = np.fromfile(</span></font><span style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);" class="">'windx_siny.bin'</span><font face="Menlo" class=""><span style="font-size: 11px;" class="">,dtype=</span></font><font color="#272AD8" face="Menlo" class=""><span style="font-size: 11px;" class="">‘>f4’</span></font><font face="Menlo" class=""><span style="font-size: 11px;" class="">)</span></font></div>
</div>
</div>
<div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255);" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""><br class="" /></span></font></div>
<div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255);" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">(you might then also want to reshape it)</span></font></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><br class="" /></div>
<div class="">This is why when you read in field tau2_1 without telling python it is big endian, it doesn’t match your tau2 field.</div>
<div class=""><br class="" /></div>
<div class="">However, I believe the reason your run is failing using the sine profile is different: as configured, the model expects single precision aka float32 files.</div>
<div class="">(MITgcm default for namelist parm <a class="external reference" href="http://mitgcm.org/lxr/ident/MITgcm?_i=readBinaryPrec">readBinaryPrec</a> is 32, i.e. float32; this can be changed in file data)</div>
<div class="">The cosine profile file in github is float32, and this works for you. However it looks like you are writing the sine profile file out as float64.</div>
<div class=""><br class="" /></div>
<div class="">Incidentally, I’ve written a python gendata.py for this tutorial, and better still, a carefully documented python script to compute and display some output</div>
<div class="">for tutorial baroclinic gyre, which you might find very helpful. These will hopefully be merged soon into the main github repository, but for</div>
<div class="">now can be found in this pull request: <a href="https://github.com/MITgcm/MITgcm/pull/386" class="">https://github.com/MITgcm/MITgcm/pull/386</a></div>
<div class=""><br class="" /></div>
<div class="">Jeff</div>
<div class=""><br class="" /></div>
<div class=""><br class="" /></div>
<div class=""><br class="" /></div>
<div class=""><br class="" /></div>
<div class="">But if you write a file <br class="" />
<div>
<blockquote type="cite" class="">
<div class="">On Apr 1, 2021, at 9:47 AM, Jan Klaus Rieck <<a href="mailto:jan.rieck@mail.mcgill.ca" class="">jan.rieck@mail.mcgill.ca</a>> wrote:</div>
<br class="Apple-interchange-newline" />
<div class="">
<div style="text-align:left; direction:ltr;" class="">
<div class="">Hello Jeremy Miller,</div>
<div class=""><br class="" /></div>
<div class="">I also use python to to generate input data for the MITgcm. I found that, to generate files that can be read by the MITgcm consistently, I needed to specify the type explicitly. </div>
<div class="">My way of saving the files would look like this in your case: </div>
<div class=""><br class="" /></div>
<div class="">if sys.byteorder == 'little': tau_2.byteswap(True)</div>
<div class="">fid = open(''windx_siny.bin', 'wb')</div>
<div class="">tau_2.astype('float32').tofile(fid)</div>
<div class=""><br class="" /></div>
<div class="">Of course, 'float32' could be replaced by 'float64' if you require double precision.</div>
<div class=""><br class="" /></div>
<div class="">I hope this helps,</div>
<div class="">Jan Rieck</div>
<div class=""> </div>
<div class="">On Thu, 2021-04-01 at 10:22 +0300, Jeremy Miller wrote:</div>
<blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex" class="">
<div dir="ltr" class="">Dear MITGCM forum,
<div class=""><br class="" /></div>
<div class="">I am Jeremy Miller, I am new to MITgcm and I've been going through the tutorials. I have a question about the "Barotropic Ocean Gyre" tutorial (section 4.1).</div>
<div class=""><br class="" /></div>
<div class="">I managed to compile and run the code, and re-produce the first two plots shown in section 4.1.5 for  wind stress of τ = τ0 cos( πy/Ly), for both the advection and non-advection cases (with the provided input binary files). </div>
<div class="">I ran into problems when trying to produce the third plot, for the case where τ = τ0 sin( πy/Ly). I am a python user, so I translated gendata.m into python to write the input binary files 'windx_cosy.bin' 'windx_siny.bin' (see the file gendata_tut4.1py attached).  As explained in section 3.9 I've included the snippet </div>
<span class="gmail-im" style="color:rgb(80,0,80)"></span>
<div class=""><span class="gmail-im" style="color:rgb(80,0,80)"><br class="" /></span></div>
<span class="gmail-im" style="color:rgb(80,0,80)"></span>
<div class=""><span class="gmail-im" style="color:rgb(80,0,80)">if sys.byteorder == 'little': tau_2.byteswap(True)</span></div>
<div class=""><span class="gmail-im" style="color:rgb(80,0,80)"><br class="" /></span></div>
<span class="gmail-im" style="color:rgb(80,0,80)"></span>
<div class="">where "tau2" is the array to be output. There was no issue in the cosine wind stress, and I managed to reproduce the results that I got with the original 'windx_cosy.bin' provided in the tutorial. However, with the sine wind stress case, the output in 'Eta.0000077760.001.001' is all zeros. </div>
<div class=""><br class="" /></div>
<div class="">When I attempt to read  'windx_siny.bin' with python into a new array called tau2_1. I get absurdly big numbers back, which do not match the original array tau2 that I created. If I Remove the snippet " if sys.byteorder == 'little': tau_2.byteswap(True) ", in the python gendata code, tau2_1 and tau2 match. But, then when I run the code again, the file output.txt contains a long list of NaNs.</div>
<span class="gmail-im" style="color:rgb(80,0,80)"></span>
<div class=""><span class="gmail-im" style="color:rgb(80,0,80)"><br class="" /></span></div>
<span class="gmail-im" style="color:rgb(80,0,80)"></span>
<div class=""><span class="gmail-im" style="color:rgb(80,0,80)">I have also included the python code used to generate the plots in the file <a href="http://tut_4.1_plots.py/" target="_blank" class="">tut_4.1_plots.py</a></span></div>
<div class=""><span class="gmail-im" style="color:rgb(80,0,80)"><br class="" /></span></div>
<span class="gmail-im" style="color:rgb(80,0,80)"></span>
<div class=""><span class="gmail-im" style="color:rgb(80,0,80)">Look forward to hearing from you.</span></div>
<div class=""><span class="gmail-im" style="color:rgb(80,0,80)">Yours sincerely</span></div>
<div class=""><span class="gmail-im" style="color:rgb(80,0,80)">Jeremy Miller</span></div>
</div>
<pre class="">_______________________________________________</pre>
<pre class="">MITgcm-support mailing list</pre>
<a href="mailto:MITgcm-support@mitgcm.org" class="">
<pre class="">MITgcm-support@mitgcm.org</pre></a>
<pre class=""><br class="" /></pre>
<a href="http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support" class="">
<pre class="">http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support</pre></a>
<pre class=""><br class="" /></pre></blockquote>
</div>
_______________________________________________<br class="" />
MITgcm-support mailing list<br class="" />
<a href="mailto:MITgcm-support@mitgcm.org" class="">MITgcm-support@mitgcm.org</a><br class="" />
http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support<br class="" /></div>
</blockquote>
</div>
<br class="" /></div>
_______________________________________________<br />
MITgcm-support mailing list<br />
MITgcm-support@mitgcm.org<br />
http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support<br /></blockquote>
</div>
</body>
</html>