Warning, /tools/TAP_support/append_fwd_src is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit 626c6ac9 on 2025-11-05 20:20:29 UTC
626c6ac944 Jean*0001 #! /usr/bin/env bash
0002
0003 #- Script to be used with Tapenade in Makefile generated with genmake2 option "-ncad":
0004 # Usage:
0005 # > append_fwd_src tap_sfx FS FILE_LIST
0006 # with:
0007 # tap_sfx :: suffix of Tapenade generated src code, either "_b" (adj) or "_d" (tlm)
0008 # FS :: (fixed-format) Fortran suffix to be used on this platform
0009 # FILE_LIST :: list of MITgcm src code to differentiate, i.e., $(AD_FILES)
0010 #
0011 # for all files in FILE_LIST :
0012 # get the name of corresponding Tapenade differentiated code with suffix "${tap_sfx}.f"
0013 # a) if Tapenade file exist, append original file to it (and rename to "${tap_sfx}.$FS")
0014 # b) if not, just copy original file to corresponding file with suffix "${tap_sfx}.$FS"
0015
0016 sfx=$1
0017 FS=$2
0018 shift ; shift
0019
0020 if test $FS = f ; then
0021 #- using default fortran suffix ".f" match Tapenade generated src code: no renaming
0022 for ff in $*
0023 do
0024 bb=`echo $ff | sed "s/\.${FS}$/${sfx}/"`
0025 xx=$bb.$FS
0026 if test -f $xx ; then
0027 #echo " cat $ff >> $xx"
0028 cat $ff >> $xx
0029 else
0030 #- Note: in this case, "-f" is not necessary if it's only used in Makefile
0031 #echo " cp $ff $xx"
0032 cp -f $ff $xx
0033 fi
0034 done
0035 else
0036 #- using a specific fortran suffix requires to rename Tapenade generated src code
0037 for ff in $*
0038 do
0039 bb=`echo $ff | sed "s/\.${FS}$/${sfx}/"`
0040 xx=$bb.$FS
0041 #- Note: in this case, "-f" is necessary (if some $xx have been left behind)
0042 if test -f $bb.f ; then
0043 #echo " cat $ff >> $xx"
0044 mv -f $bb.f $xx
0045 cat $ff >> $xx
0046 else
0047 #echo " cp $ff $xx"
0048 cp -f $ff $xx
0049 fi
0050 done
0051 fi