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

flang-new doesn't support #include of arguments #554

Open
jeffhammond opened this issue May 17, 2024 · 10 comments
Open

flang-new doesn't support #include of arguments #554

jeffhammond opened this issue May 17, 2024 · 10 comments

Comments

@jeffhammond
Copy link

I tried to compile with flang-new today and found that does not accept the #include argument method you use.

As preprocessing is not standard Fortran, this is not a flang-new bug, even if other compilers support it.

NWChem works around the lack of Fortran preprocessing by using cpp explicitly, which requires build system support.

I'm sure you have reasons for writing the code like this, but it would be nice if json-fortran was only using standard Fortran.

diff --git a/src/json_file_module.F90 b/src/json_file_module.F90
index 75376ab..09db6fe 100644
--- a/src/json_file_module.F90
+++ b/src/json_file_module.F90
@@ -502,7 +502,28 @@
 !      all have a similar interface.

     subroutine initialize_json_core_in_file(me,&
-#include "json_initialize_dummy_arguments.inc"
+!#include "json_initialize_dummy_arguments.inc"
+verbose,&
+compact_reals,&
+print_signs,&
+real_format,&
+spaces_per_tab,&
+strict_type_checking,&
+trailing_spaces_significant,&
+case_sensitive_keys,&
+no_whitespace,&
+unescape_strings,&
+comment_char,&
+path_mode,&
+path_separator,&
+compress_vectors,&
+allow_duplicate_keys,&
+escape_solidus,&
+stop_on_error,&
+null_to_real_mode,&
+non_normal_mode,&
+use_quiet_nan, &
+strict_integer_type_checking &
                                            )

     implicit none
@@ -511,7 +532,28 @@
 #include "json_initialize_arguments.inc"

     call me%core%initialize(&
-#include "json_initialize_dummy_arguments.inc"
+!#include "json_initialize_dummy_arguments.inc"
+verbose,&
+compact_reals,&
+print_signs,&
+real_format,&
+spaces_per_tab,&
+strict_type_checking,&
+trailing_spaces_significant,&
+case_sensitive_keys,&
+no_whitespace,&
+unescape_strings,&
+comment_char,&
+path_mode,&
+path_separator,&
+compress_vectors,&
+allow_duplicate_keys,&
+escape_solidus,&
+stop_on_error,&
+null_to_real_mode,&
+non_normal_mode,&
+use_quiet_nan, &
+strict_integer_type_checking &
                            )
     end subroutine initialize_json_core_in_file
 !*****************************************************************************************
@@ -568,7 +610,28 @@
 !      all have a similar interface.

     function initialize_json_file(p,&
-#include "json_initialize_dummy_arguments.inc"
+!#include "json_initialize_dummy_arguments.inc"
+verbose,&
+compact_reals,&
+print_signs,&
+real_format,&
+spaces_per_tab,&
+strict_type_checking,&
+trailing_spaces_significant,&
+case_sensitive_keys,&
+no_whitespace,&
+unescape_strings,&
+comment_char,&
+path_mode,&
+path_separator,&
+compress_vectors,&
+allow_duplicate_keys,&
+escape_solidus,&
+stop_on_error,&
+null_to_real_mode,&
+non_normal_mode,&
+use_quiet_nan, &
+strict_integer_type_checking &
                                  ) result(file_object)

     implicit none
@@ -580,7 +643,28 @@
 #include "json_initialize_arguments.inc"

     call file_object%initialize(&
-#include "json_initialize_dummy_arguments.inc"
+!#include "json_initialize_dummy_arguments.inc"
+verbose,&
+compact_reals,&
+print_signs,&
+real_format,&
+spaces_per_tab,&
+strict_type_checking,&
+trailing_spaces_significant,&
+case_sensitive_keys,&
+no_whitespace,&
+unescape_strings,&
+comment_char,&
+path_mode,&
+path_separator,&
+compress_vectors,&
+allow_duplicate_keys,&
+escape_solidus,&
+stop_on_error,&
+null_to_real_mode,&
+non_normal_mode,&
+use_quiet_nan, &
+strict_integer_type_checking &
                                )

     if (present(p)) then
@@ -637,7 +721,28 @@
 !      all have a similar interface.

     function initialize_json_file_from_string(str,&
-#include "json_initialize_dummy_arguments.inc"
+!#include "json_initialize_dummy_arguments.inc"
+verbose,&
+compact_reals,&
+print_signs,&
+real_format,&
+spaces_per_tab,&
+strict_type_checking,&
+trailing_spaces_significant,&
+case_sensitive_keys,&
+no_whitespace,&
+unescape_strings,&
+comment_char,&
+path_mode,&
+path_separator,&
+compress_vectors,&
+allow_duplicate_keys,&
+escape_solidus,&
+stop_on_error,&
+null_to_real_mode,&
+non_normal_mode,&
+use_quiet_nan, &
+strict_integer_type_checking &
                                              ) result(file_object)

     implicit none
@@ -647,7 +752,28 @@
 #include "json_initialize_arguments.inc"

     call file_object%initialize(&
-#include "json_initialize_dummy_arguments.inc"
+!#include "json_initialize_dummy_arguments.inc"
+verbose,&
+compact_reals,&
+print_signs,&
+real_format,&
+spaces_per_tab,&
+strict_type_checking,&
+trailing_spaces_significant,&
+case_sensitive_keys,&
+no_whitespace,&
+unescape_strings,&
+comment_char,&
+path_mode,&
+path_separator,&
+compress_vectors,&
+allow_duplicate_keys,&
+escape_solidus,&
+stop_on_error,&
+null_to_real_mode,&
+non_normal_mode,&
+use_quiet_nan, &
+strict_integer_type_checking &
                                )
     call file_object%deserialize(str)

@@ -659,7 +785,28 @@
 !  Alternate version of [[initialize_json_file_from_string]], where "str" is kind=CDK.

     function wrap_initialize_json_file_from_string(str,&
-#include "json_initialize_dummy_arguments.inc"
+!#include "json_initialize_dummy_arguments.inc"
+verbose,&
+compact_reals,&
+print_signs,&
+real_format,&
+spaces_per_tab,&
+strict_type_checking,&
+trailing_spaces_significant,&
+case_sensitive_keys,&
+no_whitespace,&
+unescape_strings,&
+comment_char,&
+path_mode,&
+path_separator,&
+compress_vectors,&
+allow_duplicate_keys,&
+escape_solidus,&
+stop_on_error,&
+null_to_real_mode,&
+non_normal_mode,&
+use_quiet_nan, &
+strict_integer_type_checking &
                                                   ) result(file_object)

     implicit none
@@ -670,7 +817,28 @@

     file_object = initialize_json_file_from_string(&
                                   to_unicode(str),&
-#include "json_initialize_dummy_arguments.inc"
+!#include "json_initialize_dummy_arguments.inc"
+verbose,&
+compact_reals,&
+print_signs,&
+real_format,&
+spaces_per_tab,&
+strict_type_checking,&
+trailing_spaces_significant,&
+case_sensitive_keys,&
+no_whitespace,&
+unescape_strings,&
+comment_char,&
+path_mode,&
+path_separator,&
+compress_vectors,&
+allow_duplicate_keys,&
+escape_solidus,&
+stop_on_error,&
+null_to_real_mode,&
+non_normal_mode,&
+use_quiet_nan, &
+strict_integer_type_checking &
                                                 )

     end function wrap_initialize_json_file_from_string
diff --git a/src/json_initialize_dummy_arguments.inc b/src/json_initialize_dummy_arguments.inc
index 008cbd9..0628a1d 100644
--- a/src/json_initialize_dummy_arguments.inc
+++ b/src/json_initialize_dummy_arguments.inc
@@ -1,7 +1,3 @@
-!  The dummy argument list for the various `initialize` subroutines.
-!
-!  See also: json_initialize_argument.inc
-
 verbose,&
 compact_reals,&
 print_signs,&
@@ -22,4 +18,4 @@ stop_on_error,&
 null_to_real_mode,&
 non_normal_mode,&
 use_quiet_nan, &
-strict_integer_type_checking &
\ No newline at end of file
+strict_integer_type_checking &
diff --git a/src/json_value_module.F90 b/src/json_value_module.F90
index ab890ef..be9b46a 100644
--- a/src/json_value_module.F90
+++ b/src/json_value_module.F90
@@ -979,7 +979,28 @@
 !      all have a similar interface.

     function initialize_json_core(&
-#include "json_initialize_dummy_arguments.inc"
+!#include "json_initialize_dummy_arguments.inc"
+verbose,&
+compact_reals,&
+print_signs,&
+real_format,&
+spaces_per_tab,&
+strict_type_checking,&
+trailing_spaces_significant,&
+case_sensitive_keys,&
+no_whitespace,&
+unescape_strings,&
+comment_char,&
+path_mode,&
+path_separator,&
+compress_vectors,&
+allow_duplicate_keys,&
+escape_solidus,&
+stop_on_error,&
+null_to_real_mode,&
+non_normal_mode,&
+use_quiet_nan, &
+strict_integer_type_checking &
                                  ) result(json_core_object)

     implicit none
@@ -988,7 +1009,28 @@
 #include "json_initialize_arguments.inc"

     call json_core_object%initialize(&
-#include "json_initialize_dummy_arguments.inc"
+!#include "json_initialize_dummy_arguments.inc"
+verbose,&
+compact_reals,&
+print_signs,&
+real_format,&
+spaces_per_tab,&
+strict_type_checking,&
+trailing_spaces_significant,&
+case_sensitive_keys,&
+no_whitespace,&
+unescape_strings,&
+comment_char,&
+path_mode,&
+path_separator,&
+compress_vectors,&
+allow_duplicate_keys,&
+escape_solidus,&
+stop_on_error,&
+null_to_real_mode,&
+non_normal_mode,&
+use_quiet_nan, &
+strict_integer_type_checking &
                                     )

     end function initialize_json_core
@@ -1014,7 +1056,28 @@
 !      all have a similar interface.

     subroutine json_initialize(me,&
-#include "json_initialize_dummy_arguments.inc"
+!#include "json_initialize_dummy_arguments.inc"
+verbose,&
+compact_reals,&
+print_signs,&
+real_format,&
+spaces_per_tab,&
+strict_type_checking,&
+trailing_spaces_significant,&
+case_sensitive_keys,&
+no_whitespace,&
+unescape_strings,&
+comment_char,&
+path_mode,&
+path_separator,&
+compress_vectors,&
+allow_duplicate_keys,&
+escape_solidus,&
+stop_on_error,&
+null_to_real_mode,&
+non_normal_mode,&
+use_quiet_nan, &
+strict_integer_type_checking &
                               )

     implicit none
@jacobwilliams
Copy link
Owner

Yeah, as you might be able to guess, the reason I did this was so adding a new argument didn't require me to make the same change in 10 different places. :)

Is this the only preprocessor trickery that flang-new doesn't support? (otherwise you can compile it?) Unfortunately, some of the other stuff we use the preprocessor for it was not possible to do with standard Fortran (at the time... and I assume still?) mainly the optional unicode support and support for changing the default real kind while also supporting the others (e.g. build with real128 while also supporting real32 and real64).

@jeffhammond
Copy link
Author

Yes, the above patch is all that is required to compile the whole thing. I didn't test though. I'm building Neko.

@jacobwilliams
Copy link
Owner

ah ok. Since it's just a workaround for a minor annoyance, I'm open to changing it. I'd want to run all the unit tests though (I need to see if we can get flang-new in the CI)

@jeffhammond
Copy link
Author

https://raw.githubusercontent.com/jeffhammond/HPCInfo/master/buildscripts/llvm-git.sh might be useful for CI.

I am trying to figure out how to get nightly builds packaged somewhere.

@jacobwilliams
Copy link
Owner

Note: see also: fortran-lang/setup-fortran#12

jacobwilliams added a commit that referenced this issue May 19, 2024
this usage is not supported by flang-new compiler. See #554
@jacobwilliams
Copy link
Owner

FYI: The 18.1.5 version at conda-forge is giving me:

error: loc("/home/runner/work/json-fortran/json-fortran/src/json_value_module.F90":15:5):
/home/conda/feedstock_root/build_artifacts/flang-split_1715212541315/work/flang/lib/Lower/CallInterface.cpp:948: not yet implemented: support for polymorphic types
LLVM ERROR: aborting

@jeffhammond
Copy link
Author

i recall that one was fixed a while ago but you need 19 for it. https://apt.llvm.org/ has nightly builds that include 19.

@jacobwilliams
Copy link
Owner

FYI: I've not been able to successfully get it to work from those scripts... seems like they run but then flang-new isn't in the path when it's done... (I tried various things here.. maybe I'm missing something). perhaps this is something to move to the fortran discourse and see what others are doing...

@jeffhammond
Copy link
Author

My script installs to /opt/llvm/latest and expects you to add paths manually. You can edit the script to install to /usr/local if you prefer that.

@sscalpone
Copy link

Has been implemented. llvm/llvm-project#93382

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants