New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 13027 for vendors/AGRIF/dev_r12970_AGRIF_CMEMS/AGRIF_FILES/modcurgridfunctions.F90 – NEMO

Ignore:
Timestamp:
2020-06-03T16:36:09+02:00 (4 years ago)
Author:
rblod
Message:

New AGRIF library, see ticket #2129

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendors/AGRIF/dev_r12970_AGRIF_CMEMS/AGRIF_FILES/modcurgridfunctions.F90

    r5656 r13027  
    2929    implicit none 
    3030! 
     31 
     32    interface Agrif_Parent 
     33        module procedure Agrif_Parent_Real_4,   & 
     34                         Agrif_Parent_Real_8,   & 
     35                         Agrif_Parent_Array2_Real_8,   & 
     36                         Agrif_Parent_Integer, & 
     37                         Agrif_Parent_Character, & 
     38                         Agrif_Parent_Logical 
     39    end interface 
     40    interface Agrif_Child 
     41        module procedure Agrif_Child_Logical 
     42    end interface 
     43     
    3144contains 
    3245! 
     
    657670end subroutine Agrif_Set_coeffreft_z 
    658671!=================================================================================================== 
     672!  subroutine Agrif_Set_coeffreft 
     673!--------------------------------------------------------------------------------------------------- 
     674subroutine Agrif_Set_coeffreft ( coeffref ) 
     675!--------------------------------------------------------------------------------------------------- 
     676    integer, intent(in) :: coeffref 
     677    integer :: i 
     678 
     679    if (coeffref < 0) then 
     680        write(*,*)'Coefficient of time raffinement should be positive' 
     681        stop 
     682    else 
     683        do i=1,Agrif_Probdim 
     684          Agrif_coeffreft(i) = coeffref 
     685          Agrif_Curgrid % timeref(i) = coeffref 
     686        enddo 
     687    endif 
     688!--------------------------------------------------------------------------------------------------- 
     689end subroutine Agrif_Set_coeffreft 
     690!=================================================================================================== 
    659691! 
    660692!=================================================================================================== 
     
    738770end function Agrif_Level 
    739771!=================================================================================================== 
     772!=================================================================================================== 
     773!  subroutine Agrif_set_periodicity 
     774!--------------------------------------------------------------------------------------------------- 
     775 
     776subroutine Agrif_set_periodicity(i,decal) 
     777!--------------------------------------------------------------------------------------------------- 
     778    integer :: i, decal 
     779     
     780    Agrif_curgrid%periodicity(i)=.TRUE. 
     781    Agrif_curgrid%periodicity_decal(i)=decal 
     782     
     783!--------------------------------------------------------------------------------------------------- 
     784end subroutine Agrif_set_periodicity 
    740785! 
    741786!=================================================================================================== 
     
    763808!=================================================================================================== 
    764809! 
     810 
     811function Agrif_Parent_Real_4(real_variable) result(real_variable_parent) 
     812real(KIND=4) :: real_variable 
     813real(KIND=4) :: real_variable_parent 
     814 
     815integer :: i 
     816logical :: i_found 
     817 
     818i_found = .FALSE. 
     819 
     820do i=1,Agrif_NbVariables(2) 
     821  if (LOC(real_variable) == LOC(agrif_curgrid%tabvars_r(i)%array0)) then 
     822     real_variable_parent = agrif_curgrid%tabvars_r(i)%parent_var%array0 
     823     i_found = .TRUE. 
     824     EXIT 
     825  endif 
     826enddo 
     827 
     828IF (.NOT.i_found) THEN 
     829do i=1,Agrif_NbVariables(2) 
     830  if (LOC(real_variable) == LOC(agrif_curgrid%tabvars_r(i)%sarray0)) then 
     831     real_variable_parent = agrif_curgrid%tabvars_r(i)%parent_var%sarray0 
     832     i_found = .TRUE. 
     833     EXIT 
     834  endif 
     835enddo 
     836ENDIF 
     837 
     838if (.NOT.i_found) STOP 'Agrif_Parent_Real_4 : Variable not found' 
     839 
     840end function Agrif_Parent_Real_4 
     841 
     842function Agrif_Parent_Real_8(real_variable) result(real_variable_parent) 
     843real(KIND=8) :: real_variable 
     844real(KIND=8) :: real_variable_parent 
     845 
     846integer :: i 
     847logical :: i_found 
     848 
     849i_found = .FALSE. 
     850 
     851do i=1,Agrif_NbVariables(2) 
     852  if (LOC(real_variable) == LOC(agrif_curgrid%tabvars_r(i)%array0)) then 
     853     real_variable_parent = agrif_curgrid%tabvars_r(i)%parent_var%array0 
     854     i_found = .TRUE. 
     855     EXIT 
     856  endif 
     857enddo 
     858 
     859IF (.NOT.i_found) THEN 
     860do i=1,Agrif_NbVariables(2) 
     861  if (LOC(real_variable) == LOC(agrif_curgrid%tabvars_r(i)%darray0)) then 
     862     real_variable_parent = agrif_curgrid%tabvars_r(i)%parent_var%darray0 
     863     i_found = .TRUE. 
     864     EXIT 
     865  endif 
     866enddo 
     867ENDIF 
     868 
     869if (.NOT.i_found) STOP 'Agrif_Parent_Real_8 : Variable not found' 
     870 
     871end function Agrif_Parent_Real_8 
     872 
     873function Agrif_Parent_Array2_Real_8(real_variable,ji,jj) result(real_variable_parent) 
     874real(KIND=8), DIMENSION(:,:) :: real_variable 
     875real(KIND=8) :: real_variable_parent 
     876integer :: ji,jj 
     877 
     878integer :: i 
     879logical :: i_found 
     880 
     881i_found = .FALSE. 
     882 
     883do i=1,Agrif_NbVariables(0) 
     884  if (LOC(real_variable) == LOC(agrif_curgrid%tabvars(i)%array2)) then 
     885     real_variable_parent = agrif_curgrid%tabvars(i)%parent_var%array2(ji,jj) 
     886     i_found = .TRUE. 
     887     EXIT 
     888  endif 
     889enddo 
     890 
     891if (.NOT.i_found) STOP 'Agrif_Parent_Array2_Real_8 : Variable not found' 
     892 
     893end function Agrif_Parent_Array2_Real_8 
     894 
     895 
     896function Agrif_Parent_Integer(integer_variable) result(integer_variable_parent) 
     897integer :: integer_variable 
     898integer :: integer_variable_parent 
     899 
     900integer :: i 
     901logical :: i_found 
     902 
     903i_found = .FALSE. 
     904 
     905do i=1,Agrif_NbVariables(4) 
     906  if (LOC(integer_variable) == LOC(agrif_curgrid%tabvars_i(i)%iarray0)) then 
     907     integer_variable_parent = agrif_curgrid%tabvars_i(i)%parent_var%iarray0 
     908     i_found = .TRUE. 
     909     EXIT 
     910  endif 
     911enddo 
     912 
     913if (.NOT.i_found) STOP 'Agrif_Parent : Variable not found' 
     914 
     915end function Agrif_Parent_Integer 
     916 
     917function Agrif_Parent_Character(character_variable) result(character_variable_parent) 
     918character(*) :: character_variable 
     919character(len(character_variable)) :: character_variable_parent 
     920 
     921integer :: i 
     922logical :: i_found 
     923 
     924i_found = .FALSE. 
     925 
     926do i=1,Agrif_NbVariables(1) 
     927  if (LOC(character_variable) == LOC(agrif_curgrid%tabvars_c(i)%carray0)) then 
     928     character_variable_parent = agrif_curgrid%tabvars_c(i)%parent_var%carray0 
     929     i_found = .TRUE. 
     930     EXIT 
     931  endif 
     932enddo 
     933 
     934if (.NOT.i_found) STOP 'Agrif_Parent : Variable not found' 
     935 
     936end function Agrif_Parent_Character 
     937 
     938function Agrif_Parent_Logical(logical_variable) result(logical_variable_parent) 
     939logical :: logical_variable 
     940logical :: logical_variable_parent 
     941 
     942integer :: i 
     943logical :: i_found 
     944 
     945i_found = .FALSE. 
     946 
     947do i=1,Agrif_NbVariables(3) 
     948  if (LOC(logical_variable) == LOC(agrif_curgrid%tabvars_l(i)%larray0)) then 
     949     logical_variable_parent = agrif_curgrid%tabvars_l(i)%parent_var%larray0 
     950     i_found = .TRUE. 
     951     EXIT 
     952  endif 
     953enddo 
     954 
     955if (.NOT.i_found) STOP 'Agrif_Parent : Variable not found' 
     956 
     957end function Agrif_Parent_Logical 
     958 
     959function Agrif_Child_Logical(logical_variable) result(logical_variable_child) 
     960logical :: logical_variable 
     961logical :: logical_variable_child 
     962 
     963integer :: i 
     964logical :: i_found 
     965 
     966i_found = .FALSE. 
     967 
     968do i=1,Agrif_NbVariables(3) 
     969  if (LOC(logical_variable) == LOC(agrif_curgrid%tabvars_l(i)%larray0)) then 
     970     logical_variable_child = Agrif_CurChildgrid%tabvars_l(i)%larray0 
     971     i_found = .TRUE. 
     972     EXIT 
     973  endif 
     974enddo 
     975 
     976if (.NOT.i_found) STOP 'Agrif_Child : Variable not found' 
     977 
     978end function Agrif_Child_Logical 
     979 
     980function Agrif_Irhox() result(i_val) 
     981integer :: i_val 
     982i_val = agrif_curgrid%spaceref(1) 
     983end function Agrif_Irhox 
     984 
     985function Agrif_Irhoy() result(i_val) 
     986integer :: i_val 
     987i_val = agrif_curgrid%spaceref(2) 
     988end function Agrif_Irhoy 
     989 
     990function Agrif_Irhoz() result(i_val) 
     991integer :: i_val 
     992i_val = agrif_curgrid%spaceref(3) 
     993end function Agrif_Irhoz 
     994 
     995function Agrif_NearCommonBorderX() result(l_val) 
     996logical :: l_val 
     997l_val = agrif_curgrid%nearRootBorder(1) 
     998end function Agrif_NearCommonBorderX 
     999 
     1000subroutine Agrif_Set_NearCommonBorderX(l_val) 
     1001logical,intent(in) :: l_val 
     1002agrif_curgrid%nearRootBorder(1)=l_val 
     1003end subroutine Agrif_Set_NearCommonBorderX 
     1004 
     1005function Agrif_NearCommonBorderY() result(l_val) 
     1006logical :: l_val 
     1007l_val = agrif_curgrid%nearRootBorder(2) 
     1008end function Agrif_NearCommonBorderY 
     1009 
     1010subroutine Agrif_Set_NearCommonBorderY(l_val) 
     1011logical,intent(in) :: l_val 
     1012agrif_curgrid%nearRootBorder(2)=l_val 
     1013end subroutine Agrif_Set_NearCommonBorderY 
     1014 
     1015function Agrif_NearCommonBorderZ() result(l_val) 
     1016logical :: l_val 
     1017l_val = agrif_curgrid%nearRootBorder(3) 
     1018end function Agrif_NearCommonBorderZ 
     1019 
     1020subroutine Agrif_Set_NearCommonBorderZ(l_val) 
     1021logical,intent(in) :: l_val 
     1022agrif_curgrid%nearRootBorder(3)=l_val 
     1023end subroutine Agrif_Set_NearCommonBorderZ 
     1024 
     1025function Agrif_DistantCommonBorderX() result(l_val) 
     1026logical :: l_val 
     1027l_val = agrif_curgrid%DistantRootBorder(1) 
     1028end function Agrif_DistantCommonBorderX 
     1029 
     1030subroutine Agrif_Set_DistantCommonBorderX(l_val) 
     1031logical,intent(in) :: l_val 
     1032agrif_curgrid%DistantRootBorder(1)=l_val 
     1033end subroutine Agrif_Set_DistantCommonBorderX 
     1034 
     1035function Agrif_DistantCommonBorderY() result(l_val) 
     1036logical :: l_val 
     1037l_val = agrif_curgrid%DistantRootBorder(2) 
     1038end function Agrif_DistantCommonBorderY 
     1039 
     1040subroutine Agrif_Set_DistantCommonBorderY(l_val) 
     1041logical,intent(in) :: l_val 
     1042agrif_curgrid%DistantRootBorder(2)=l_val 
     1043end subroutine Agrif_Set_DistantCommonBorderY 
     1044 
     1045function Agrif_DistantCommonBorderZ() result(l_val) 
     1046logical :: l_val 
     1047l_val = agrif_curgrid%DistantRootBorder(3) 
     1048end function Agrif_DistantCommonBorderZ 
     1049 
     1050subroutine Agrif_Set_DistantCommonBorderZ(l_val) 
     1051logical,intent(in) :: l_val 
     1052agrif_curgrid%DistantRootBorder(3)=l_val 
     1053end subroutine Agrif_Set_DistantCommonBorderZ 
     1054 
     1055function Agrif_Ix() result(i_val) 
     1056integer :: i_val 
     1057i_val = agrif_curgrid%ix(1) 
     1058end function Agrif_Ix 
     1059 
     1060function Agrif_Iy() result(i_val) 
     1061integer :: i_val 
     1062i_val = agrif_curgrid%ix(2) 
     1063end function Agrif_Iy 
     1064 
     1065function Agrif_Iz() result(i_val) 
     1066integer :: i_val 
     1067i_val = agrif_curgrid%ix(3) 
     1068end function Agrif_Iz 
     1069 
     1070function Agrif_Get_grid_id() result(i_val) 
     1071integer :: i_val 
     1072i_val = agrif_curgrid % grid_id 
     1073end function Agrif_Get_grid_id 
     1074 
     1075function Agrif_Get_parent_id() result(i_val) 
     1076integer :: i_val 
     1077i_val = agrif_curgrid % parent % grid_id 
     1078end function Agrif_Get_parent_id 
     1079 
     1080function Agrif_rhox() result(r_val) 
     1081real :: r_val 
     1082r_val = real(agrif_curgrid%spaceref(1)) 
     1083end function Agrif_rhox 
     1084 
     1085function Agrif_rhoy() result(r_val) 
     1086real :: r_val 
     1087r_val = real(agrif_curgrid%spaceref(2)) 
     1088end function Agrif_rhoy 
     1089 
     1090function Agrif_rhoz() result(r_val) 
     1091real :: r_val 
     1092r_val = real(agrif_curgrid%spaceref(3)) 
     1093end function Agrif_rhoz 
     1094 
     1095function Agrif_Nb_Step() result(i_val) 
     1096integer :: i_val 
     1097i_val = agrif_curgrid%ngridstep 
     1098end function Agrif_Nb_Step 
     1099 
     1100function Agrif_Nb_Fine_Grids() result(i_val) 
     1101integer :: i_val 
     1102i_val = Agrif_nbfixedgrids 
     1103end function Agrif_Nb_Fine_Grids 
     1104 
     1105! Set the name of the External mapping subroutine (if needed) 
     1106subroutine Agrif_Set_ExternalMapping(external_mapping) 
     1107Procedure(mapping) :: external_mapping 
     1108 
     1109agrif_external_mapping => external_mapping 
     1110 
     1111end subroutine Agrif_Set_ExternalMapping 
     1112 
     1113! Set the name of the user linear interp function (if needed) 
     1114subroutine Agrif_Set_external_linear_interp(external_linear_interp) 
     1115Procedure(linear_interp) :: external_linear_interp 
     1116 
     1117agrif_external_linear_interp => external_linear_interp 
     1118 
     1119end subroutine Agrif_Set_external_linear_interp 
     1120 
     1121subroutine Agrif_UnSet_external_linear_interp() 
     1122 
     1123nullify(agrif_external_linear_interp) 
     1124 
     1125end subroutine Agrif_UnSet_external_linear_interp 
     1126 
    7651127end module Agrif_CurgridFunctions 
Note: See TracChangeset for help on using the changeset viewer.