Changeset 2439 for trunk


Ignore:
Timestamp:
Dec 22, 2020, 11:51:50 AM (4 years ago)
Author:
emillour
Message:

Common dynamics:
Add a check that input fields (read from start.nc file) indeed have
matching values along the longitude end points when they should,
and if not correct field at longitude index iimp1 to match value
at longitude index 1.
EM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/dyn3d_common/dynetat0.F90

    r2337 r2439  
    329329  CHARACTER(LEN=*), INTENT(IN)  :: var
    330330  REAL,             INTENT(OUT) :: v(:,:)
     331  INTEGER :: j
    331332  CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var)
    332333  CALL err(NF90_GET_VAR(fID,vID,v),"get",var)
     334  ! Check that if on iip1 points along the longitude
     335  ! values indeed perfectly match at end points
     336  if (size(v,1)==iip1) then
     337    do j=1,size(v,2)
     338      if (v(1,j).ne.v(iip1,j)) then
     339        ! tell the world
     340        write(*,*) "Warning: longitudinal modulo discrepency for ",trim(var)
     341        write(*,*) "j=",j," v(1,j)=",v(1,j)," v(iip1,j)=",v(iip1,j)
     342        ! copy over value from v(1,j) to v(iip1,j)
     343        write(*,*) "setting v(iip1,j)=v(1,j)"
     344        v(iip1,j)=v(1,j)
     345      endif ! of if (v(1,j).ne.v(iip1,j))
     346    enddo ! of do j=1,size(v,2)
     347  endif ! of if (size(v,1)==iip1)
    333348END SUBROUTINE get_var2
    334349
     
    337352  REAL,             INTENT(OUT) :: v(:,:)
    338353  INTEGER, INTENT(IN) :: indextime
     354  INTEGER :: j
    339355  corner(1)=1
    340356  corner(2)=1
     
    345361  CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var)
    346362  CALL err(NF90_GET_VAR(fID,vID,v,corner,edges),"get",var)
     363  ! Check that if on iip1 points along the longitude
     364  ! values indeed perfectly match at end points
     365  if (size(v,1)==iip1) then
     366    do j=1,size(v,2)
     367      if (v(1,j).ne.v(iip1,j)) then
     368        ! tell the world
     369        write(*,*) "Warning: longitudinal modulo discrepency for ",trim(var)
     370        write(*,*) "j=",j," v(1,j)=",v(1,j)," v(iip1,j)=",v(iip1,j)
     371        ! copy over value from v(1,j) to v(iip1,j)
     372        write(*,*) "setting v(iip1,j)=v(1,j)"
     373        v(iip1,j)=v(1,j)
     374      endif ! of if (v(1,j).ne.v(iip1,j))
     375    enddo ! of do j=1,size(v,2)
     376  endif ! of if (size(v,1)==iip1)
    347377END SUBROUTINE get_var2_t
    348378
     
    359389  REAL,             INTENT(OUT) :: v(:,:,:)
    360390  INTEGER, INTENT(IN) :: indextime
     391  INTEGER :: j,k
    361392  corner(1)=1
    362393  corner(2)=1
     
    369400  CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var)
    370401  CALL err(NF90_GET_VAR(fID,vID,v,corner,edges),"get",var)
     402  ! Check that values indeed perfectly match at end points along longitude
     403  do k=1,llm
     404    do j=1,jjp1
     405      if (v(1,j,k).ne.v(iip1,j,k)) then
     406        ! tell the world
     407        write(*,*) "Warning: longitudinal modulo discrepency for ",trim(var)
     408        write(*,*) "j=",j," k=",k
     409        write(*,*) " v(1,j,k)=",v(1,j,k)," v(iip1,j,k)=",v(iip1,j,k)
     410        ! copy over value from v(1,j,k) to v(iip1,j,k)
     411        write(*,*) "setting v(iip1,j,k)=v(1,j,k)"
     412        v(iip1,j,k)=v(1,j,k)
     413      endif ! of if (v(1,j,k).ne.v(iip1,j,k))
     414    enddo ! of do j=1,jjp1
     415  enddo ! of do k=1,llm
    371416END SUBROUTINE get_var3u_t
    372417
     
    375420  REAL,             INTENT(OUT) :: v(:,:,:)
    376421  INTEGER, INTENT(IN) :: indextime
     422  INTEGER :: j,k
    377423  corner(1)=1
    378424  corner(2)=1
     
    385431  CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var)
    386432  CALL err(NF90_GET_VAR(fID,vID,v,corner,edges),"get",var)
     433  ! Check that values indeed perfectly match at end points along longitude
     434  do k=1,llm
     435    do j=1,jjm
     436      if (v(1,j,k).ne.v(iip1,j,k)) then
     437        ! tell the world
     438        write(*,*) "Warning: longitudinal modulo discrepency for ",trim(var)
     439        write(*,*) "j=",j," k=",k
     440        write(*,*) " v(1,j,k)=",v(1,j,k)," v(iip1,j,k)=",v(iip1,j,k)
     441        ! copy over value from v(1,j,k) to v(iip1,j,k)
     442        write(*,*) "setting v(iip1,j,k)=v(1,j,k)"
     443        v(iip1,j,k)=v(1,j,k)
     444      endif ! of if (v(1,j,k).ne.v(iip1,j,k))
     445    enddo ! of do j=1,jjm
     446  enddo ! of do k=1,llm
    387447END SUBROUTINE get_var3v_t
    388448
Note: See TracChangeset for help on using the changeset viewer.