[MITgcm-devel] testreport on my mac
Martin Losch
Martin.Losch at awi.de
Thu Apr 4 09:09:13 EDT 2019
Hi again,
I seem to be bored so here’s my suggestion (after testing a lot of different stuff):
adm_diva_nb=`sed -n '/^ *add_DIVA_runs *=/p' run_ADM_DIVA | sed 's/ //g'`
This will catch the space “ “ (or no space) before the “=“ sign. One could also do “^ *add_DIVA_runs.*=“, then it would find also things like "add_DIVA_runsxxx =“. I am not sure why this is so complicated anyway. Do we plan to have many variants of run_ADV_DIVA, anyway?
If no-one has a better idea, I’ll create PR soon.
Martin
> On 3. Apr 2019, at 18:05, Martin Losch <Martin.Losch at awi.de> wrote:
>
> Hi Jean-Michel and all sed gurus out there,
>
> maybe not so important, but on my MacOS, I cannot run testreport on lab_sea.ad because my “sed” doesn’t give me the correct output when excuting l831:
> bkli04m001::run> sed -n '/^ *add_DIVA_runs\>.*=/p' run_ADM_DIVA | sed 's/ //g'
> bkli04m001::run>
>
> gives nothing, but
>>> sed '/^ *add_DIVA_runs\>.*=/p' run_ADM_DIVA | sed 's/ //g'
> #----------usedbytestreportforDividedAdjointRun:----------
> #numberofadditionalexecutionstoperformisgivenby"add_DIVA_runs"
> #andcorrespondsto"nchklev_3"valueinfile"code_ad/tamc.h"
> add_DIVA_runs=4
>
> I am using /usr/bin/sed, which is a BSD sed, so I am assuming that it doesn’t know about fancy gnu extensions
>
> On my linux box with a gnu sed, version 4.2.2, I am getting:
>
> bkli04l006::run> sed -n '/^ *add_DIVA_runs\>.*=/p' run_ADM_DIVA | sed 's/ //g'
> add_DIVA_runs=4
>
> and
> bkli04l006::run> sed '/^ *add_DIVA_runs\>.*=/p' run_ADM_DIVA | sed 's/ //g'
> #----------usedbytestreportforDividedAdjointRun:----------
> #numberofadditionalexecutionstoperformisgivenby"add_DIVA_runs"
> #andcorrespondsto"nchklev_3"valueinfile"code_ad/tamc.h"
> add_DIVA_runs=4
> add_DIVA_runs=4
>
> Obviously, the problem is that my BSD sed does not understand the search pattern. I don’t understand it either, that’s why I cannot suggest anything better that does the same thing, but does not rely on GNU extensions. I tried this:
> sed -n '/^add_DIVA_runs/p' run_ADM_DIVA | sed 's/ //g’
>
> on both MacOS (BSD) and linux and that seems to work (ie. gives the correct answer), but I have no idea, what side effects this may have.
> Any suggestions?
>
> Martin
> _______________________________________________
> MITgcm-devel mailing list
> MITgcm-devel at mitgcm.org
> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-devel
More information about the MITgcm-devel
mailing list