-
Notifications
You must be signed in to change notification settings - Fork 8
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
Pull back data to legacy structures on device #49
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bd4a696
Add utility functions transfering between Field API objects and old P…
pmarguinaud c013f44
Merge branch 'main' of https://github.com/ecmwf-ifs/field_api into ho…
pmarguinaud f62599c
Fix memory location
pmarguinaud 8134866
Fix access mode in LEGACY util
pmarguinaud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
! (C) Copyright 2022- ECMWF. | ||
! (C) Copyright 2022- Meteo-France. | ||
! | ||
! This software is licensed under the terms of the Apache Licence Version 2.0 | ||
! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
! In applying this licence, ECMWF does not waive the privileges and immunities | ||
! granted to it by virtue of its status as an intergovernmental organisation | ||
! nor does it submit to any jurisdiction. | ||
|
||
PROGRAM TEST_LEGACY | ||
|
||
USE FIELD_MODULE | ||
USE FIELD_FACTORY_MODULE | ||
USE FIELD_ACCESS_MODULE | ||
USE FIELD_ABORT_MODULE | ||
USE FIELD_CONSTANTS_MODULE | ||
USE FIELD_UTIL_MODULE, ONLY : LEGACY, LEGACY_FIELD_3RD | ||
|
||
USE PARKIND1 | ||
|
||
IMPLICIT NONE | ||
|
||
CLASS(FIELD_3RB), POINTER :: FU, FV, FT | ||
|
||
REAL(KIND=JPRB), ALLOCATABLE :: GMV (:,:,:,:) | ||
|
||
REAL(KIND=JPRB), POINTER :: U (:,:,:), V (:,:,:), T (:,:,:) | ||
|
||
INTEGER, PARAMETER :: NFLEVG = 5, NPROMA = 32, NGPBLKS = 4, NDIM = 3 | ||
INTEGER, PARAMETER :: IU = 1, IV = 2, IT = 3 | ||
|
||
INTEGER*8 :: IADDRL, IADDRU | ||
|
||
INTEGER :: JLON, JLEV, JBLK | ||
INTEGER :: IERR | ||
|
||
ALLOCATE (GMV (NPROMA, NFLEVG, NDIM, NGPBLKS)) | ||
|
||
GMV = 0._JPRB | ||
|
||
CALL FIELD_NEW (FU, DATA=GMV (:,:,IU,:)) | ||
CALL FIELD_NEW (FV, DATA=GMV (:,:,IV,:)) | ||
CALL FIELD_NEW (FT, DATA=GMV (:,:,IT,:)) | ||
|
||
! All fields on the device | ||
|
||
U => GET_DEVICE_DATA_RDWR (FU) | ||
V => GET_DEVICE_DATA_RDONLY (FV) | ||
T => GET_DEVICE_DATA_RDONLY (FT) | ||
|
||
!$acc kernels present (U) | ||
U = 1._JPRB | ||
!$acc end kernels | ||
|
||
!$acc enter data create (GMV) | ||
!$acc update device (GMV) | ||
|
||
IADDRL = LOC (GMV (1,1,1,1)) | ||
IADDRU = LOC (GMV(NPROMA,NFLEVG,NDIM,NGPBLKS)) | ||
|
||
CALL LEGACY_FIELD_3RD (FU, KADDRL=IADDRL, KADDRU=IADDRU, KDIR=NF2L) | ||
|
||
IERR = 0 | ||
|
||
!$acc serial present (GMV) copy (IERR) | ||
|
||
DO JBLK = 1, NGPBLKS | ||
DO JLEV = 1, NFLEVG | ||
DO JLON = 1, NPROMA | ||
IF (GMV (JLON,JLEV,IU,JBLK) /= 1._JPRB) THEN | ||
IERR = IERR + 1 | ||
ENDIF | ||
GMV (JLON,JLEV,IV,JBLK) = 2._JPRB | ||
ENDDO | ||
ENDDO | ||
ENDDO | ||
|
||
!$acc end serial | ||
|
||
IF (IERR /= 0) CALL FIELD_ABORT ('VALUE MISMATCH: KDIR=NF2L') | ||
|
||
CALL LEGACY_FIELD_3RD (FV, KADDRL=IADDRL, KADDRU=IADDRU, KDIR=NL2F) | ||
|
||
U => GET_DEVICE_DATA_RDONLY (FU) | ||
V => GET_DEVICE_DATA_RDONLY (FV) | ||
T => GET_DEVICE_DATA_RDONLY (FT) | ||
|
||
IERR = 0 | ||
|
||
!$acc serial present (U, V, T) copy (IERR) | ||
|
||
DO JBLK = 1, NGPBLKS | ||
DO JLEV = 1, NFLEVG | ||
DO JLON = 1, NPROMA | ||
|
||
IF (U (JLON, JLEV, JBLK) /= 1._JPRB) THEN | ||
IERR = IERR + 1 | ||
ENDIF | ||
|
||
IF (V (JLON, JLEV, JBLK) /= 2._JPRB) THEN | ||
IERR = IERR + 1 | ||
ENDIF | ||
|
||
IF (T (JLON, JLEV, JBLK) /= 0._JPRB) THEN | ||
IERR = IERR + 1 | ||
ENDIF | ||
|
||
ENDDO | ||
ENDDO | ||
ENDDO | ||
|
||
!$acc end serial | ||
|
||
IF (IERR /= 0) CALL FIELD_ABORT ('VALUE MISMATCH: KDIR=NL2F') | ||
|
||
!$acc exit data delete (GMV) | ||
|
||
CALL FIELD_DELETE (FT) | ||
CALL FIELD_DELETE (FV) | ||
CALL FIELD_DELETE (FU) | ||
|
||
DEALLOCATE (GMV) | ||
|
||
END PROGRAM |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[no action] Since GMV has been allocated by the time we get here, we can simply do
!$acc enter data copyin
.