Commit 5358d3ff authored by ymeur's avatar ymeur
Browse files

Fix openMP for new version of nudging.

YM
parent ed7dff09
Pipeline #160943 failed with stages
in 2 minutes and 29 seconds
......@@ -76,29 +76,32 @@ CONTAINS
CHARACTER(*), OPTIONAL, INTENT(IN) :: name, suffix, pname
INTEGER :: ind
field%do_vertical_remap = do_vertical_remap
field%name = TRIM(name) ! note that name is in fact a compulsory argument
field%suffix =""
IF (PRESENT(suffix)) field%suffix = TRIM(suffix)
field%is_ps = PRESENT(pname)
IF(field%is_ps) field%pname = TRIM(pname)
field%is_q = .FALSE.
IF (PRESENT(dim4) .AND. dim4 == nqtot) field%is_q = .TRUE.
!$OMP BARRIER
IF (is_omp_master) THEN
field%do_vertical_remap = do_vertical_remap
field%name = TRIM(name) ! note that name is in fact a compulsory argument
field%suffix =""
IF (PRESENT(suffix)) field%suffix = TRIM(suffix)
field%is_ps = PRESENT(pname)
IF(field%is_ps) field%pname = TRIM(pname)
field%is_q = .FALSE.
IF (PRESENT(dim4) .AND. dim4 == nqtot) field%is_q = .TRUE.
IF (is_omp_master) CALL xios_get_axis_attr("axis_nudged",n_glo=field%nlevels)
CALL bcast_omp(field%nlevels)
ALLOCATE(field%levels(field%nlevels))
CALL xios_get_axis_attr("axis_nudged",n_glo=field%nlevels)
ALLOCATE(field%levels(field%nlevels))
IF (is_omp_master) CALL xios_get_axis_attr("axis_nudged",value=field%levels)
CALL bcast_omp(field%levels)
IF (is_omp_master) CALL xios_get_axis_attr("axis_nudged",value=field%levels)
! CALL bcast_omp(field%levels)
IF (PRESENT(dim4)) THEN
field%ndim=4
ELSE IF (PRESENT(dim3)) THEN
field%ndim=3
ELSE
field%ndim=2
IF (PRESENT(dim4)) THEN
field%ndim=4
ELSE IF (PRESENT(dim3)) THEN
field%ndim=3
ELSE
field%ndim=2
ENDIF
ENDIF
!$OMP BARRIER
IF (field%do_vertical_remap .AND. PRESENT(dim3)) THEN
CALL allocate_field(field%f_t0, field_type, data_type, field%nlevels, dim4, name=TRIM(name)//'_t0')
......@@ -200,17 +203,20 @@ CONTAINS
REAL(rstd) :: t0,t1
INTEGER :: iq,l,ind
LOGICAL :: test
IF(interp%read_t0) THEN
! we get data for t0 only once, from XIOS field XXX0
IF (field%is_q) THEN ! for tracers
DO iq=1,nqtot
! CALL xios_read_field(TRIM(tracers(iq)%name)//TRIM(field%suffix)//"0", field%f_tmp)
IF (xios_is_valid_field(TRIM(tracers(iq)%name)//TRIM(field%suffix))) THEN
IF (is_omp_master) test =xios_is_valid_field(TRIM(tracers(iq)%name)//TRIM(field%suffix))
CALL bcast_omp(test)
IF (test) THEN
CALL xios_read_field(TRIM(tracers(iq)%name)//TRIM(field%suffix)//"0", field%f_tmp)
ELSE
DO ind=1,ndomain
field%f_tmp(ind)%rval4d(:,:,:)=0
IF (is_omp_first_level) field%f_tmp(ind)%rval4d(:,:,:)=0
ENDDO
ENDIF
......@@ -218,14 +224,13 @@ CONTAINS
IF(.NOT. assigned_domain(ind)) CYCLE
CALL swap_dimensions(ind)
CALL swap_geometry(ind)
! DO l=ll_begin,ll_end
field%f_t0(ind)%rval4d(:,:,iq) = field%f_tmp(ind)%rval4d(:,:,1)
! ENDDO
IF (is_omp_first_level) field%f_t0(ind)%rval4d(:,:,iq) = field%f_tmp(ind)%rval4d(:,:,1)
ENDDO
ENDDO
ELSE
CALL xios_read_field(TRIM(field%name)//"0", field%f_t0)
ENDIF
!$OMP BARRIER
SELECT CASE(field%f_t0(1)%field_type)
CASE(field_T)
......@@ -241,9 +246,10 @@ CONTAINS
IF (.NOT. field%do_vertical_remap) THEN
IF(field%is_ps) THEN
DO ind=1,ndomain
f_ps(ind)%rval4d = field%f_t0(ind)%rval4d
IF(.NOT. assigned_domain(ind)) CYCLE
IF (is_omp_first_level) f_ps(ind)%rval4d = field%f_t0(ind)%rval4d
ENDDO
!$OMP BARRIER
CALL pression_mid(field%f_t0, f_p)
CALL xios_write_field(TRIM(field%pname)//"0",f_p)
ENDIF
......@@ -255,25 +261,27 @@ CONTAINS
IF(interp%read_t1) THEN
IF (field%is_q) THEN ! for tracers
DO iq=1,nqtot
IF (xios_is_valid_field(TRIM(tracers(iq)%name)//TRIM(field%suffix))) THEN
IF (is_omp_master) test = xios_is_valid_field(TRIM(tracers(iq)%name)//TRIM(field%suffix))
CALL bcast_omp(test)
IF (test) THEN
CALL xios_read_field(TRIM(tracers(iq)%name)//TRIM(field%suffix), field%f_tmp)
ELSE
DO ind=1,ndomain
field%f_tmp(ind)%rval4d(:,:,:)=0
IF(.NOT. assigned_domain(ind)) CYCLE
IF (is_omp_first_level) field%f_tmp(ind)%rval4d(:,:,:)=0
ENDDO
!$OMP BARRIER
ENDIF
DO ind=1,ndomain
IF(.NOT. assigned_domain(ind)) CYCLE
CALL swap_dimensions(ind)
CALL swap_geometry(ind)
! DO l=ll_begin,ll_end
field%f_t1(ind)%rval4d(:,:,iq) = field%f_tmp(ind)%rval4d(:,:,1)
! ENDDO
IF (is_omp_first_level) field%f_t1(ind)%rval4d(:,:,iq) = field%f_tmp(ind)%rval4d(:,:,1)
ENDDO
!$OMP BARRIER
ENDDO
ELSE
CALL xios_read_field(TRIM(field%name), field%f_t1)
ENDIF
......@@ -309,8 +317,8 @@ CONTAINS
TYPE(t_field), POINTER,OPTIONAL,INTENT(IN) :: f_ps(:)
INTEGER :: ind, n
!$OMP BARRIER
DO ind=1, ndomain
IF(.NOT. assigned_domain(ind)) CYCLE
IF (field%do_vertical_remap .AND. field%ndim>2) THEN
n = SIZE(field%f_levels(ind)%rval4d)
CALL compute_interpolate_time_field(interp%coef0, interp%coef1, n, &
......
......@@ -153,23 +153,23 @@ CONTAINS
ENDIF
! activate nudging in XIOS workflow
CALL xios_set_filegroup_attr("nudging_files",enabled=.TRUE.)
CALL xios_set_fieldgroup_attr("nudging_fields",read_access=.TRUE.)
CALL xios_set_fieldgroup_attr("nudging_fields0",read_access=.TRUE.)
IF (is_omp_master) CALL xios_set_filegroup_attr("nudging_files",enabled=.TRUE.)
IF (is_omp_master) CALL xios_set_fieldgroup_attr("nudging_fields",read_access=.TRUE.)
IF (is_omp_master) CALL xios_set_fieldgroup_attr("nudging_fields0",read_access=.TRUE.)
! switch XIOS worklow to do or not vertical interpolation in the workflow
IF (do_vertical_remap) THEN
! vertical remapping is done with the model
CALL xios_set_axis_attr("from_nudged",axis_ref="axis_nudged")
CALL xios_set_axis_attr("from_nudged0",axis_ref="axis_nudged")
CALL xios_set_field_attr("p_nudged_horiz_interp",read_access=.FALSE.)
CALL xios_set_field_attr("p_nudged_horiz_interp0",read_access=.FALSE.)
IF (is_omp_master) CALL xios_set_axis_attr("from_nudged",axis_ref="axis_nudged")
IF (is_omp_master) CALL xios_set_axis_attr("from_nudged0",axis_ref="axis_nudged")
IF (is_omp_master) CALL xios_set_field_attr("p_nudged_horiz_interp",read_access=.FALSE.)
IF (is_omp_master) CALL xios_set_field_attr("p_nudged_horiz_interp0",read_access=.FALSE.)
ELSE
! vertical remapping is done in XIOS workflow
CALL xios_set_axis_attr("from_nudged",axis_ref="nudged_vert_interp_src_dest")
CALL xios_set_axis_attr("from_nudged0",axis_ref="nudged_vert_interp_src_dest")
CALL xios_set_field_attr("p_nudged_horiz_interp",read_access=.TRUE.)
CALL xios_set_field_attr("p_nudged_horiz_interp0",read_access=.TRUE.)
IF (is_omp_master) CALL xios_set_axis_attr("from_nudged",axis_ref="nudged_vert_interp_src_dest")
IF (is_omp_master) CALL xios_set_axis_attr("from_nudged0",axis_ref="nudged_vert_interp_src_dest")
IF (is_omp_master) CALL xios_set_field_attr("p_nudged_horiz_interp",read_access=.TRUE.)
IF (is_omp_master) CALL xios_set_field_attr("p_nudged_horiz_interp0",read_access=.TRUE.)
ENDIF
END SUBROUTINE pre_init_guided
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment