Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifs to genmake2 and adjoint_default to enable mixed .f .f90 with TAF #709

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

heimbach
Copy link
Collaborator

@heimbach heimbach commented Mar 9, 2023

What changes does this PR introduce?

  • We want to be able to add to TAF_COMMON_FLAGS via genmake_local
  • changes to genmake2 to enable mixed .F and .F90 code for TAF

What is the current behaviour?

(You can also link to an open issue here)

What is the new behaviour

(if this is a feature change)?

Does this PR introduce a breaking change?

(What changes might users need to make in their application due to this PR?)

Other information:

Suggested addition to tag-index

(To avoid unnecessary merge conflicts, please don't update tag-index. One of the admins will do that when merging your pull request.)

* changes to genmake2 to enable mixed .F and .F90 code for TAF
@jm-c jm-c requested a review from mjlosch March 9, 2023 04:57
@jm-c jm-c added the adjoint Affects the adjoint model; label triggers full OpenAD test label Mar 9, 2023
@mjlosch
Copy link
Member

mjlosch commented Mar 9, 2023

Hi Patrick, I always wanted to to be able to use both *.F90 and F. files.
But I tried (on my arm64 MacBook with gfortran) :

 ./testreport -t isomip -adm -devel
...
Y Y N N .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. N/O   isomip  (e=100, w=0, lfd=0, dop=0, sm=0)
Y Y N N .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. N/O   isomip.htd

the taf output in make.tr_log starts with

file ad_input_code.for:
     1 cadj SUBROUTINE active_read_xy FTLNAME = g_active_read_xy
            ^
*ERROR* : = expected
                       ^
*ERROR* : end of line expected
     2 cadj SUBROUTINE active_read_xy ADNAME  = adactive_read_xy
            ^

and I tried

./testreport -t isomip -adm -ncad -devel
...
Y Y N N .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. N/O   isomip
Y Y N N .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. N/O   isomip.htd

Here, TAF does not seem to be called at all leading to a missing _adthe_main_loop_ in the link step.
Assuming that this works for you, do you have any idea which parts of the changes may cause this?

Copy link
Member

@mjlosch mjlosch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a complete review and maybe just notes about the changes. I tried to run testreport -adm -t isomip again on a linux box, where it works, but not with -ncad. So two issues:

  1. -ncad does not work (for me)
  2. this does not work on MacOS (I assume shell tools are the problem)

I will try to find a fix for MacOS later. In the meantime, does it make sense to have an example with mixed .F and .F90 files in the verification experiments?

tools/genmake2 Outdated
Comment on lines 3344 to 3345
sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_F90FILES:.$FS90=_ad.$FS90)
@-rm -f \$(AD_F90FILES:.$FS90=_ad.$FS90.bak)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the same for target ftl_sed (next couple of lines)?

tools/genmake2 Outdated
\$(MAKE) -f \$(MAKEFILE) remove_comments
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) \$(FLOWFILES) \$(AD_FILES)
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) all_flowfiles.$FS \$(AD_FILES) \$(AD_F90FILES)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that this line has to do with my failing compilation.

@@ -1817,7 +1817,7 @@ if test "x${AD_OPTFILE}" != xNONE ; then
exit 1
fi
fi
if test $CAT_SRC_FOR_TAF = 0 ; then TAF_EXTRA="${TAF_EXTRA} -fixed" ; fi
### if test $CAT_SRC_FOR_TAF = 0 ; then TAF_EXTRA="${TAF_EXTRA} -fixed" ; fi
Copy link
Member

@mjlosch mjlosch Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? I thought (and I may be wrong) that our f90 files all need to be fixed format anyway.
When I add a -fixed to the taf-command, then at least the code without -nocat4ad/-ncad compiles and the isomip experiment runs. (but the -ncad test still does not work)

When I put back this line, I get no complaint from taf for testreport -adm -ncad, but a problem with target adj_sed (which may be related to the sed version on my laptop, which does not allow an empty list of input files $(AD_F90FILES) ).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this line had to be commented out to allow for free format code to be passed to TAF. The -fixed flag is the fortran compiler flag to enforce fixed-form.

@mjlosch
Copy link
Member

mjlosch commented Mar 9, 2023

With these changes, it seems to work for me also with MacOS. @heimbach do you want me to push this, or would you rather try this first.

modified   tools/genmake2
@@ -1817,7 +1817,9 @@ if test "x${AD_OPTFILE}" != xNONE ; then
 	exit 1
     fi
 fi
-### if test $CAT_SRC_FOR_TAF = 0 ; then TAF_EXTRA="${TAF_EXTRA} -fixed" ; fi
+# this seems to be necessary because we now mix .F and .F90 files
+TAF_EXTRA="${TAF_EXTRA} -fixed"
 
 #====================================================================
 # Initialize INCLUDEDIRSMK from and optfile INCLUDEDIRS
@@ -3339,10 +3341,8 @@ remove_comments:
 	sed -i.bak -f \$(TOOLSDIR)/remove_comments_sed \$(AD_FILES)
 	@-rm -f \$(AD_FILES:.$FS=.$FS.bak)
 adj_sed:
-	sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_ad.$FS)
-	@-rm -f \$(AD_FILES:.$FS=_ad.$FS.bak)
-	sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_F90FILES:.$FS90=_ad.$FS90)
-	@-rm -f \$(AD_F90FILES:.$FS90=_ad.$FS90.bak)
+	sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_ad.$FS) \$(AD_F90FILES:.$FS90=_ad.$FS90)
+	@-rm -f \$(AD_FILES:.$FS=_ad.$FS.bak) \$(AD_F90FILES:.$FS90=_ad.$FS90.bak)
 ftl_sed:
 	sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_tl.$FS)
 	@-rm -f \$(AD_FILES:.$FS=_tl.$FS.bak)
@@ -3416,11 +3416,10 @@ ad_taf_output.$FS: \$(AD_FLOW_FILES) \$(AD_FILES) \$(AD_F90FILES)
 	@\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
 	@\$(MAKE) -f \$(MAKEFILE) \$(F90_PP_SRC_FILES)
 	@\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
-	cat \$(FLOWFILES) > all_flowfiles.$FS
 	@-rm -f \$(AD_FILES:.$FS=_ad.$FS) \$(AD_FILES:.$FS=_ad.o); echo ''
 	@-rm -f \$(AD_F90FILES:.$FS90=_ad.$FS90) \$(AD_F90FILES:.$FS90=_ad.o); echo ''
 	\$(MAKE) -f \$(MAKEFILE) remove_comments
-	\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) all_flowfiles.$FS \$(AD_FILES) \$(AD_F90FILES)
+	\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) \$(FLOWFILES) \$(AD_FILES) \$(AD_F90FILES)
 	\$(MAKE) -f \$(MAKEFILE) adj_sed
 	cat \$(AD_FILES:.$FS=_ad.$FS) > ad_taf_output.$FS

@heimbach
Copy link
Collaborator Author

heimbach commented Mar 9, 2023 via email

@heimbach
Copy link
Collaborator Author

heimbach commented Mar 9, 2023 via email

@heimbach
Copy link
Collaborator Author

heimbach commented Mar 9, 2023 via email

@mjlosch
Copy link
Member

mjlosch commented Mar 9, 2023

@heimbach I took the liberty to edit your posts (stripped the original messages that the emails replied to) to make it easier to follow this thread.

Thanks for the explanations, I now understand more of the changes. Is still work in progress, or is this already ready for review? If it is work in progress, we should add the corresponding label or make it a draft PR and I will hold off any further amateur attempts to make this work for me (it seems that make and Makefiles are my personal enemy).

Otherwise, I am not sure what to do here. The first thing I normally do is check if this PR breaks anything. I just used isomip, because it is usually fast to process (for taf), but the problem is the same for all other experiments. Also with lab_sea, the target adj_sed fails. When I fix this (see above just for adj_sed: move \$(AD_F90FILES:.$FS90=_ad.$FS90) to the same line as $(AD_FILES:.$FS=_ad.$FS)), the lab_sea experiment compiles on a linux box (but not on my Mac, because the target adtaf is not made. I need to remove all_flowfiles.$FS to make it work there, and I am not sure why the -fixed flag is necessary, either. Let's leave the Mac issue for now), but it stops with this error (on linux):

>  MDS_READ_FIELD: filename: ./ctrl_variables/adxx_atemp.0000000000 , ./ctrl_variables/adxx_atemp.0000000000.001.001.data
>  MDS_READ_FIELD: Files DO not exist
>  additional DIVA run # 3 : done
> STOP ABNORMAL END: S/R MDS_READ_FIELD
>  MDS_READ_FIELD: filename: ./ctrl_variables/adxx_atemp.0000000000 , ./ctrl_variables/adxx_atemp.0000000000.001.001.data
>  MDS_READ_FIELD: Files DO not exist
>  additional DIVA run # 4 : done
> STOP ABNORMAL END: S/R MDS_READ_FIELD
>  MDS_READ_FIELD: filename: ./ctrl_variables/adxx_atemp.0000000000 , ./ctrl_variables/adxx_atemp.0000000000.001.001.data
>  MDS_READ_FIELD: Files DO not exist

@heimbach
Copy link
Collaborator Author

heimbach commented Mar 9, 2023 via email

@mjlosch
Copy link
Member

mjlosch commented Mar 10, 2023

I am also getting correct _ad.f files (after my fixes of adj_sed), but none of the AD testreport experiments pass. Either they do not compile (even after fixing adj_sed), or there are runtime issues with missing adxx_ files.
I think that the problem is related to specifics of make. Different make seem to expect different things (e.g. the line cat \$(FLOWFILES) > all_flowfiles.$FS makes my GNU Make 3.81 omit the target adtaf completely).
I suggest to

  1. make it work with the testreport suite on a linux box
  2. ensure that at the same time your specific set up still works.
  3. address make issues with other implementations of make/operating systems later

for 2.: couldn't we just modify an existing experiment and add a new free-form routine that is called from a local file like cost_test.F (to be honest I didn't think that compiling fixed together free from code is possible with our include files and common blocks)

In the meantime I'll add the work-in-progress label.

@mjlosch mjlosch added the work in progress Should not be merged until this label is removed label Mar 10, 2023
@mjlosch
Copy link
Member

mjlosch commented Mar 10, 2023

I think I have a solution to the first issue (testreport experiments failing). Basically the same as for the target adj_sed: If the file list $(F90_PP_SRC_FILES) is empty (as for almost all experiments), then the line

	@\$(MAKE) -f \$(MAKEFILE) \$(F90_PP_SRC_FILES)

in genmake2 expands into

	make -f Makefile

without any files and this will then make the target mitgcmuv. I could push a modification to solve these issues and then you can check if it still works for your case. Let me know.

Also I think I know now why stuff is failing on the Mac: The filesystem does not differentiate between upper and lower case, so that the file suffixes $FS and $FS90 do not expand into f and f90, but into for and fr9, and I guess TAF does not understand that. That's why there is the -fixed option to make TAF understand that we are sending fixed-form source files. I guess this will be a fundamental problem for your approach. Or do you think we can convince TAF to accept these unusual suffixes? Fortran compilers do not seem to have a problem with that.

tools/genmake2 Outdated
Comment on lines 3416 to 3420
@\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
@\$(MAKE) -f \$(MAKEFILE) \$(F90_PP_SRC_FILES)
@\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
cat \$(FLOWFILES) > all_flowfiles.$FS
@-rm -f \$(AD_FILES:.$FS=_ad.$FS) \$(AD_FILES:.$FS=_ad.o); echo ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we do not need the FLOWFILES, and we could just use AD_FLOW_FILES, as the links are concatenated into a local file anyway. And, more importantly, we should combine the two "PP" lines, as shown below, so that F90_PP_SRC_FILES can be empty without problems:

Suggested change
@\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
@\$(MAKE) -f \$(MAKEFILE) \$(F90_PP_SRC_FILES)
@\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
cat \$(FLOWFILES) > all_flowfiles.$FS
@-rm -f \$(AD_FILES:.$FS=_ad.$FS) \$(AD_FILES:.$FS=_ad.o); echo ''
@\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
cat \$(AD_FLOW_FILES) > all_flowfiles.$FS
@-rm -f \$(AD_FILES:.$FS=_ad.$FS) \$(AD_FILES:.$FS=_ad.o); echo ''

tools/genmake2 Outdated
Comment on lines 3342 to 3345
sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_ad.$FS)
@-rm -f \$(AD_FILES:.$FS=_ad.$FS.bak)
sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_F90FILES:.$FS90=_ad.$FS90)
@-rm -f \$(AD_F90FILES:.$FS90=_ad.$FS90.bak)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is necessary if AD_F90FILES is empty (which is the case most of the time)

Suggested change
sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_ad.$FS)
@-rm -f \$(AD_FILES:.$FS=_ad.$FS.bak)
sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_F90FILES:.$FS90=_ad.$FS90)
@-rm -f \$(AD_F90FILES:.$FS90=_ad.$FS90.bak)
sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_ad.$FS) \$(AD_F90FILES:.$FS90=_ad.$FS90)
@-rm -f \$(AD_FILES:.$FS=_ad.$FS.bak) \$(AD_F90FILES:.$FS90=_ad.$FS90.bak)

@mjlosch
Copy link
Member

mjlosch commented Mar 16, 2023

with the TAF 5.8.0 we can now specify both fixed and free format files with arbitrary suffixes like this

staf [options] -fixed fixed_format_file.for -free free_format_file.fr9

This solves the MacOS issue and it is no longer necessary concatenate all *.flow files into a new files with suffix .f.

@heimbach I can push a solution that contains all my previous suggestions, modified to work with TAF 5.8.0 for you to try. Let me know.

- on MacOS, file systems are case-insensitive by default; we solve
that by using different file extensions for preprocessed files (.for
and .fr9); with TAF version 5.8.0 and higher, we can specify both
fixed and free format files at the command line with appropriate
flags; this also require an update of the staf script
- add more lines to remove from preprocess files before sending them
to taf.
@mjlosch
Copy link
Member

mjlosch commented Apr 18, 2023

@heimbach please try my latest commit. You need to install the latest staf script for this (staf -get).

@antnguyen13
Copy link
Collaborator

@mjlosch i'm going to try this... please stay tuned for some questions :-)

@IvanaEscobar
Copy link
Contributor

Hi all,

Thanks @mjlosch for pointing me to this PR!

I am also getting correct _ad.f files (after my fixes of adj_sed), but none of the AD testreport experiments pass. Either they do not compile (even after fixing adj_sed), or there are runtime issues with missing adxx_ files. I think that the problem is related to specifics of make.

It looks like the new genmake2 file never updates AD_CONFIG.h, leaving ALLOW_ADJOINT_RUN undefined. This is what causes adxx_* files to never write.

@mjlosch
Copy link
Member

mjlosch commented Apr 3, 2024

@IvanaEscobar I made the comment you are referring to on Mar 10, 2023. I have committed fixes since (e37d726). It would be great if you could try them.

@IvanaEscobar
Copy link
Contributor

IvanaEscobar commented Apr 3, 2024

I've updated genmake2 with @mjlosch 's committed fixes, and it seems to pass the one testreport I ran, not sure if the summary stating "Not enough lines..." matters.

Ran:

>>> cd verification/
>>> ./testreport -adm -ncad -t tutorial_global_oce_optim

Results:
Screenshot 2024-04-03 at 1 23 36 PM


My changes are in a forked branch of MITgcm, genmake2_hybrid

In that branch there are some potentially irrelevant contributions:

  1. genmake_local allowing TAF to extend source lines up to 132 columns (-e)
  2. adjoint_hybrid compile options file, which was suggested as a change adjoint_default in this PR. This allows for users to pass flags to TAF that aren't conventionally considered in genmake2

These modifications do not cause my targeted testreport to fail. Can specify adjoint options files in testreport

./testreport -adm -ncad -t tutorial_global_oce_optim -adof ../tools/adjoint_options/adjoint_hybrid

@mjlosch
Copy link
Member

mjlosch commented Apr 4, 2024

@IvanaEscobar It's great that it works for you, thanks for testing.
You'll find that "Not enough lines..." also happens with the master-branch. It just means that we did not turn on the adjMonitorFreq for this experiment (by choice).

About your branch genmake2_hybrid: I quickly looked at the differences with this branch and have these comments:

  1. The changes in genmake2 cover the changes made in your version in genmake2_hybrid, don't they?
  2. The -e option can already be specified in genmake_local by setting USE_EXTENDED_SRC='t', there is an example in verification/bottom_ctrl_5x5/build/genmake_local (or put this directly in the build-options file). Please try this with your specific configuration (i.e. not the tutorials or verification experiments) if this is already doing what you expect it to do.
  3. adjoint_hybrid on your branch genmake2_hybrid is identical to the modified adjoint_default on this branch, right?
  4. instead of adjoint_default, one can specify different AD-option files via genmake_local, and there is an example in verification/bottom_ctrl_5x5/build/genmake_local, and via the genmake2 -adoptfile=... flag. Extending this to testreport sounds like a good idea. Out of curiosity: is it possible to add these taf-specific flags to testreport -optfile=... file?
  5. one can find adjoint_default in the documenation, maybe not very prominently. To me, this is the file (or a different version of this specified by -adjoptfile), where the taf-specific flags should go. The (undocumented) flags TAF_FORTRAN_VERS and (with this PR) TAF_COMMON_FLAGS (to be set in genmake_local) add some flexibility if one wants to test different things with the same adjoint options file.
  6. On my MacBook, genmake2_hybrid does not work.

I have this suggestion:
If @IvanaEscobar and @antnguyen13 can already use the genmake2 from this PR for their work (and if @heimbach agrees), I suggest to merge this PR as soon as possible and ask @IvanaEscobar to add the testreport contribution (point 4) in a separate PR. In fact, from what I see, such as PR would be completely independent of this PR and could be made even without this PR.

@IvanaEscobar
Copy link
Contributor

IvanaEscobar commented Apr 5, 2024

@mjlosch, I've checked on your points and address each one below:

@IvanaEscobar It's great that it works for you, thanks for testing. You'll find that "Not enough lines..." also happens with the master-branch. It just means that we did not turn on the adjMonitorFreq for this experiment (by choice).

About your branch genmake2_hybrid: I quickly looked at the differences with this branch and have these comments:

  1. The changes in genmake2 cover the changes made in your version in genmake2_hybrid, don't they?

The changes in my branch are identical to this PR.

  1. The -e option can already be specified in genmake_local by setting USE_EXTENDED_SRC='t', there is an example in verification/bottom_ctrl_5x5/build/genmake_local (or put this directly in the build-options file). Please try this with your specific configuration (i.e. not the tutorials or verification experiments) if this is already doing what you expect it to do.

Changing to USE_EXTENDED_SRC='t' works, which means we have two different ways of accomplishing passing -e?

  1. adjoint_hybrid on your branch genmake2_hybrid is identical to the modified adjoint_default on this branch, right?

The adjoint_hybrid is fully defined by adjoint_default in this PR.

  1. instead of adjoint_default, one can specify different AD-option files via genmake_local, and there is an example in verification/bottom_ctrl_5x5/build/genmake_local, and via the genmake2 -adoptfile=... flag. Extending this to testreport sounds like a good idea. Out of curiosity: is it possible to add these taf-specific flags to testreport -optfile=... file?

Leaving adoptfile as it's done in genmake2, as a unique option, allows for a user to ./testreport with a default optfile instead of iterating over which optfile works best followed by appending ad compile options to that file. I tried appending an optfile with a modified adjoint_default, which resulted in repitition of TAF-specific flags:

AD_TAF_FLAGS         = -f95 -e -i4 -r4 -intrinsic system,flush -reverse -l taf_ad.log -f95 -e -i4 -r4 -intrinsic system,flush -reverse -l taf_ad.log -toplevel 'the_main_loop' -input 'xx_obcsn_dummy xx_obcss_dummy xx_obcsw_dummy xx_obcse_dummy xx_genarr2d_dummy xx_genarr3d_dummy xx_gentim2d_dummy' -output 'fc' -toplevel 'the_main_loop' -input 'xx_obcsn_dummy xx_obcss_dummy xx_obcsw_dummy xx_obcse_dummy xx_genarr2d_dummy xx_genarr3d_dummy xx_gentim2d_dummy' -output 'fc'
FTL_TAMC_FLAGS       = -forward -ftlmark g_ -i4 -r4 -l tamc_ftl.log -forward -ftlmark g_ -i4 -r4 -l tamc_ftl.log -toplevel 'the_main_loop' -input 'xx_obcsn_dummy xx_obcss_dummy xx_obcsw_dummy xx_obcse_dummy xx_genarr2d_dummy xx_genarr3d_dummy xx_gentim2d_dummy' -output 'fc' -toplevel 'the_main_loop' -input 'xx_obcsn_dummy xx_obcss_dummy xx_obcsw_dummy xx_obcse_dummy xx_genarr2d_dummy xx_genarr3d_dummy xx_gentim2d_dummy' -output 'fc'
FTL_TAF_FLAGS        = -f95 -e -i4 -r4 -intrinsic system,flush -forward -l taf_ftl.log -f95 -e -i4 -r4 -intrinsic system,flush -forward -l taf_ftl.log -toplevel 'the_main_loop' -input 'xx_obcsn_dummy xx_obcss_dummy xx_obcsw_dummy xx_obcse_dummy xx_genarr2d_dummy xx_genarr3d_dummy xx_gentim2d_dummy' -output 'fc' -toplevel 'the_main_loop' -input 'xx_obcsn_dummy xx_obcss_dummy xx_obcsw_dummy xx_obcse_dummy xx_genarr2d_dummy xx_genarr3d_dummy xx_gentim2d_dummy' -output 'fc'

This seems to be genmake2 assuming adjoint_default TAF-specific flags before an -optfile is read.

  1. one can find adjoint_default in the documenation, maybe not very prominently. To me, this is the file (or a different version of this specified by -adjoptfile), where the taf-specific flags should go. The (undocumented) flags TAF_FORTRAN_VERS and (with this PR) TAF_COMMON_FLAGS (to be set in genmake_local) add some flexibility if one wants to test different things with the same adjoint options file.
  2. On my MacBook, genmake2_hybrid does not work.

Is this a .fr9 based issue? I ended up abandoning master branch's genmake2 in favor of one that generalized F90 file endings for the Mac environment. Works for forward models, based on the last set-ups I created in MacOS M2 environment. fwd genmake2 MacOS

I have this suggestion: If @IvanaEscobar and @antnguyen13 can already use the genmake2 from this PR for their work (and if @heimbach agrees), I suggest to merge this PR as soon as possible and ask @IvanaEscobar to add the testreport contribution (point 4) in a separate PR. In fact, from what I see, such as PR would be completely independent of this PR and could be made even without this PR.

This PR works for me, so let's hope it works for @antnguyen13 as well. I can set-up a separate PR for testreport

@jm-c
Copy link
Member

jm-c commented Apr 5, 2024

I did not follow the details, so just a side comment about a new testreport option:
I think it's nice when we can use testreport for multiple experiments (i.e., the default). If this new option allows to test an experiment that uses a mix of fixed and free-format code but does not work for current experiment that only use fixed-format, then it's probably better to leave this in the genmake_local.

@mjlosch
Copy link
Member

mjlosch commented Apr 9, 2024

@IvanaEscobar

10. On my MacBook, genmake2_hybrid does not work.

Is this a .fr9 based issue? I ended up abandoning master branch's genmake2 in favor of one that generalized F90 file endings for the Mac environment. Works for forward models, based on the last set-ups I created in MacOS M2 environment. fwd genmake2 MacOS

I hope that I am getting this right: in fwd genmake2 MacOS you modified this line 3258

      \$(TOOLSDIR)/f90mkdepend -fs $FS -fs90 $FS90 >> \$(MAKEFILE)

to include -fs $FS -fs90 $FS90. Is this something that we should add to this PR?

In this PR there are a lot of changes that relate to the TAF-AD generation, but there are no changes to forward-code generation. We could add this if it does not break anything (or again a different PR, your pick). I think genmake2_hybrid fails on my MacBook, because of missing pieces for the AD code, but I didn't check closely.

@IvanaEscobar
Copy link
Contributor

@IvanaEscobar

  1. On my MacBook, genmake2_hybrid does not work.

Is this a .fr9 based issue? I ended up abandoning master branch's genmake2 in favor of one that generalized F90 file endings for the Mac environment. Works for forward models, based on the last set-ups I created in MacOS M2 environment. fwd genmake2 MacOS

I hope that I am getting this right: in fwd genmake2 MacOS you modified this line 3258

      \$(TOOLSDIR)/f90mkdepend -fs $FS -fs90 $FS90 >> \$(MAKEFILE)

to include -fs $FS -fs90 $FS90. Is this something that we should add to this PR?

Anything related to MacBook M1/2/3 could be addressed separately. This PR seems ready to go as is, unless @antnguyen13 finds issues with running.

@@ -34,7 +34,7 @@ AD_TAF_FLAGS="-reverse $DIVA_FLAG -l taf_ad.log $AD_TAF_FLAGS"
FTL_TAF_FLAGS="-forward -l taf_ftl.log $FTL_TAF_FLAGS"
SVD_TAF_FLAGS="-reverse -forward -pure -l taf_svd.log $SVD_TAF_FLAGS"

TAF_COMMON_FLAGS="-i4 -r4 -intrinsic system,flush"
TAF_COMMON_FLAGS="$TAF_COMMON_FLAGS -i4 -r4 -intrinsic system,flush"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes it possible add TAF_COMMON_FLAGS to genmake_local, however, it duplicates the functionality of TAF_EXTRA (see, for example, verification/lab_sea/build/genmake_local). There is also a genmake2-flag -taf_extra that allows specifying extra flags for TAF. Given these available options, I do not see why we need a third way of specifying extra flags for TAF.
Further, TAF_COMMON_FLAGS was intended as an internal abbreviation for flags common to all versions of TAF/TAMC, so using it for a different purpose may be confusing in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adjoint Affects the adjoint model; label triggers full OpenAD test work in progress Should not be merged until this label is removed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants