Changeset 5116 for LMDZ6/branches/Amaury_dev/libf/misc
- Timestamp:
- Jul 24, 2024, 2:54:37 PM (2 months ago)
- Location:
- LMDZ6/branches/Amaury_dev/libf/misc
- Files:
-
- 1 added
- 5 deleted
- 11 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
LMDZ6/branches/Amaury_dev/libf/misc/lmdz_assert.f90
r5113 r5116 15 15 CHARACTER(LEN = *), INTENT(IN) :: string 16 16 LOGICAL, INTENT(IN) :: n1 17 if (.not. n1) then17 if (.not. n1) THEN 18 18 write (*, *) 'nrerror: an assertion failed with this tag:', & 19 19 string … … 26 26 CHARACTER(LEN = *), INTENT(IN) :: string 27 27 LOGICAL, INTENT(IN) :: n1, n2 28 if (.not. (n1 .and. n2)) then28 if (.not. (n1 .and. n2)) THEN 29 29 write (*, *) 'nrerror: an assertion failed with this tag:', & 30 30 string … … 37 37 CHARACTER(LEN = *), INTENT(IN) :: string 38 38 LOGICAL, INTENT(IN) :: n1, n2, n3 39 if (.not. (n1 .and. n2 .and. n3)) then39 if (.not. (n1 .and. n2 .and. n3)) THEN 40 40 write (*, *) 'nrerror: an assertion failed with this tag:', & 41 41 string … … 48 48 CHARACTER(LEN = *), INTENT(IN) :: string 49 49 LOGICAL, INTENT(IN) :: n1, n2, n3, n4 50 if (.not. (n1 .and. n2 .and. n3 .and. n4)) then50 if (.not. (n1 .and. n2 .and. n3 .and. n4)) THEN 51 51 write (*, *) 'nrerror: an assertion failed with this tag:', & 52 52 string … … 59 59 CHARACTER(LEN = *), INTENT(IN) :: string 60 60 LOGICAL, DIMENSION(:), INTENT(IN) :: n 61 if (.not. all(n)) then61 if (.not. all(n)) THEN 62 62 write (*, *) 'nrerror: an assertion failed with this tag:', & 63 63 string -
LMDZ6/branches/Amaury_dev/libf/misc/lmdz_coefpoly.f90
r5114 r5116 1 1 module lmdz_coefpoly 2 2 3 IMPLICIT NONE 3 IMPLICIT NONE; PRIVATE 4 PUBLIC coefpoly 4 5 5 6 contains … … 25 26 ! a0, a1, a2, a3. 26 27 27 use nrtype, only: k828 use nrtype, ONLY: k8 28 29 29 30 REAL(K8), intent(in) :: xf1, xf2, xprim1, xprim2, xtild1, xtild2 -
LMDZ6/branches/Amaury_dev/libf/misc/lmdz_formcoord.f90
r5115 r5116 1 MODULE lmdz_formcoord 2 IMPLICIT NONE; PRIVATE 3 PUBLIC formcoord 4 CONTAINS 1 5 2 ! $Header$ 6 SUBROUTINE formcoord(unit, n, x, a, rev, text) 7 IMPLICIT NONE 8 INTEGER :: n, unit, ndec 9 logical :: rev 10 REAL :: x(n), a 11 CHARACTER(LEN = 4) :: text 3 12 4 SUBROUTINE formcoord(unit,n,x,a,rev,text) 5 IMPLICIT NONE 6 integer :: n,unit,ndec 7 logical :: rev 8 real :: x(n),a 9 character(len=4) :: text 13 INTEGER :: i, id, i1, i2, in 14 REAL :: dx, dxmin 10 15 11 integer :: i,id,i1,i2,in 12 real :: dx,dxmin 16 IF(rev) THEN 17 id = -1 18 i1 = n 19 i2 = n - 1 20 in = 1 21 WRITE(unit, 3000) text(1:1) 22 else 23 id = 1 24 i1 = 1 25 i2 = 2 26 in = n 27 endif 13 28 14 if(rev) then 15 id=-1 16 i1=n 17 i2=n-1 18 in=1 19 write(unit,3000) text(1:1) 20 else 21 id=1 22 i1=1 23 i2=2 24 in=n 25 endif 29 if (n<2) THEN 30 ndec = 1 31 WRITE(unit, 1000) text, n, x(1) * a 32 else 33 dxmin = abs(x(2) - x(1)) 34 do i = 2, n - 1 35 dx = abs(x(i + 1) - x(i)) 36 if (dx<dxmin) dxmin = dx 37 enddo 26 38 27 if (n<2) then28 ndec=129 write(unit,1000) text,n,x(1)*a30 else31 dxmin=abs(x(2)-x(1))32 do i=2,n-133 dx=abs(x(i+1)-x(i))34 if (dx<dxmin) dxmin=dx35 enddo39 ndec = -log10(dxmin) + 2 40 IF(mod(n, 6)==1) THEN 41 WRITE(unit, 1000) text, n, x(i1) * a 42 WRITE(unit, 2000) (x(i) * a, i=i2, in, id) 43 else 44 WRITE(unit, 1000) text, n 45 WRITE(unit, 2000) (x(i) * a, i=i1, in, id) 46 endif 47 endif 36 48 37 ndec=-log10(dxmin)+2 38 if(mod(n,6)==1) then 39 write(unit,1000) text,n,x(i1)*a 40 write(unit,2000) (x(i)*a,i=i2,in,id) 41 else 42 write(unit,1000) text,n 43 write(unit,2000) (x(i)*a,i=i1,in,id) 44 endif 45 endif 49 1000 format(a4, 2x, i4, ' LEVELS', 43x, f12.2) 50 2000 format(6f12.2) 51 3000 format('FORMAT ', a1, 'REV') 46 52 47 1000 format(a4,2x,i4,' LEVELS',43x,f12.2) 48 2000 format(6f12.2) 49 !1000 format(a4,2x,i4,' LEVELS',43x,f12.<ndec>) 50 !2000 format(6f12.<ndec>) 51 3000 format('FORMAT ',a1,'REV') 52 53 54 end subroutine formcoord 53 END SUBROUTINE formcoord 54 END MODULE lmdz_formcoord -
LMDZ6/branches/Amaury_dev/libf/misc/lmdz_interpolation.f90
r5115 r5116 1 1 ! $Id$ 2 module interpolation2 module lmdz_interpolation 3 3 4 4 ! From Press et al., 1996, version 2.10a 5 5 ! B3 Interpolation and Extrapolation 6 6 7 IMPLICIT NONE 7 IMPLICIT NONE; PRIVATE 8 PUBLIC locate, hunt 8 9 9 10 contains 10 11 11 pure FUNCTION locate(xx, x)12 pure FUNCTION locate(xx, x) 12 13 13 14 REAL, DIMENSION(:), INTENT(IN) :: xx … … 22 23 ! See notes. 23 24 24 INTEGER n, jl,jm,ju25 INTEGER n, jl, jm, ju 25 26 LOGICAL ascnd 26 27 27 28 !---------------------------- 28 29 29 n =size(xx)30 n = size(xx) 30 31 ascnd = (xx(n) >= xx(1)) 31 32 ! (True if ascending order of table, false otherwise.) 32 33 ! Initialize lower and upper limits: 33 jl =034 ju =n+135 do while (ju -jl > 1)36 jm=(ju+jl)/2 ! Compute a midpoint,37 if (ascnd .eqv. (x >= xx(jm))) then38 jl=jm ! and replace either the lower limit39 40 ju=jm ! or the upper limit, as appropriate.41 34 jl = 0 35 ju = n + 1 36 do while (ju - jl > 1) 37 jm = (ju + jl) / 2 ! Compute a midpoint, 38 if (ascnd .eqv. (x >= xx(jm))) THEN 39 jl = jm ! and replace either the lower limit 40 else 41 ju = jm ! or the upper limit, as appropriate. 42 end if 42 43 END DO 43 44 ! {ju == jl + 1} … … 48 49 49 50 ! Then set the output, being careful with the endpoints: 50 if (x == xx(1)) then51 locate=152 else if (x == xx(n)) then53 locate=n-151 if (x == xx(1)) THEN 52 locate = 1 53 else if (x == xx(n)) THEN 54 locate = n - 1 54 55 else 55 locate=jl56 locate = jl 56 57 end if 57 58 … … 60 61 !*************************** 61 62 62 pure SUBROUTINE hunt(xx, x,jlo)63 pure SUBROUTINE hunt(xx, x, jlo) 63 64 64 65 ! Given an array xx(1:N ), and given a value x, returns a value … … 72 73 REAL, INTENT(IN) :: x 73 74 REAL, DIMENSION(:), INTENT(IN) :: xx 74 INTEGER n, inc,jhi,jm75 INTEGER n, inc, jhi, jm 75 76 LOGICAL ascnd, hunt_up 76 77 77 78 !----------------------------------------------------- 78 79 79 n =size(xx)80 n = size(xx) 80 81 ascnd = (xx(n) >= xx(1)) 81 82 ! (True if ascending order of table, false otherwise.) 82 if (jlo < 0 .or. jlo > n) then83 84 jlo=085 jhi=n+183 if (jlo < 0 .or. jlo > n) THEN 84 ! Input guess not useful. Go immediately to bisection. 85 jlo = 0 86 jhi = n + 1 86 87 else 87 inc=1 ! Set the hunting increment.88 if (jlo == 0) then89 90 91 92 93 94 95 jhi=jlo+inc96 97 jhi=n+198 99 100 101 jlo=jhi ! Not done hunting,102 inc=inc+inc ! so double the increment103 104 105 106 jhi=jlo107 108 jlo=jhi-inc109 110 jlo=0111 112 113 114 jhi=jlo ! Not done hunting,115 inc=inc+inc ! so double the increment116 117 118 88 inc = 1 ! Set the hunting increment. 89 if (jlo == 0) THEN 90 hunt_up = .TRUE. 91 else 92 hunt_up = x >= xx(jlo) .eqv. ascnd 93 end if 94 if (hunt_up) then ! Hunt up: 95 do 96 jhi = jlo + inc 97 if (jhi > n) then ! Done hunting, since off end of table. 98 jhi = n + 1 99 exit 100 else 101 if (x < xx(jhi) .eqv. ascnd) exit 102 jlo = jhi ! Not done hunting, 103 inc = inc + inc ! so double the increment 104 end if 105 END DO ! and try again. 106 else ! Hunt down: 107 jhi = jlo 108 do 109 jlo = jhi - inc 110 if (jlo < 1) then ! Done hunting, since off end of table. 111 jlo = 0 112 exit 113 else 114 if (x >= xx(jlo) .eqv. ascnd) exit 115 jhi = jlo ! Not done hunting, 116 inc = inc + inc ! so double the increment 117 end if 118 END DO ! and try again. 119 end if 119 120 end if ! Done hunting, value bracketed. 120 121 121 122 do ! Hunt is done, so begin the final bisection phase: 122 if (jhi-jlo <= 1) then123 if (x == xx(n)) jlo=n-1124 if (x == xx(1)) jlo=1125 126 127 jm=(jhi+jlo)/2128 if (x >= xx(jm) .eqv. ascnd) then129 jlo=jm130 131 jhi=jm132 133 123 if (jhi - jlo <= 1) THEN 124 if (x == xx(n)) jlo = n - 1 125 if (x == xx(1)) jlo = 1 126 exit 127 else 128 jm = (jhi + jlo) / 2 129 if (x >= xx(jm) .eqv. ascnd) THEN 130 jlo = jm 131 else 132 jhi = jm 133 end if 134 end if 134 135 END DO 135 136 136 137 END SUBROUTINE hunt 137 138 138 end module interpolation139 end module lmdz_interpolation -
LMDZ6/branches/Amaury_dev/libf/misc/lmdz_libmath_pch.f90
r5115 r5116 489 489 ! the points XE. 490 490 491 use lmdz_assert_eq, only: assert_eq491 use lmdz_assert_eq, ONLY: assert_eq 492 492 493 493 REAL, intent(in) :: X(:) ! real array of independent variable values … … 572 572 ! 2001, pages 43-47 573 573 574 use lmdz_assert_eq, only: assert_eq574 use lmdz_assert_eq, ONLY: assert_eq 575 575 576 576 real, intent(in) :: x(:) … … 638 638 639 639 n = assert_eq(size(x), size(f), "pchsp_95 n") 640 if ((ibeg == 1 .or. ibeg == 2) .and. .not. present(vc_beg)) then640 if ((ibeg == 1 .or. ibeg == 2) .and. .not. present(vc_beg)) THEN 641 641 print *, "vc_beg required for IBEG = 1 or 2" 642 642 stop 1 643 643 end if 644 if ((iend == 1 .or. iend == 2) .and. .not. present(vc_end)) then644 if ((iend == 1 .or. iend == 2) .and. .not. present(vc_end)) THEN 645 645 print *, "vc_end required for IEND = 1 or 2" 646 646 stop 1 -
LMDZ6/branches/Amaury_dev/libf/misc/lmdz_xer.f90
r5115 r5116 748 748 ! intrinsic function LEN is used to determine its length. If 749 749 ! it is zero, PREFIX is not used. If it exceeds 16 or if 750 ! LEN(PREFIX) exceeds 16, onlythe first 16 characters will be750 ! LEN(PREFIX) exceeds 16, ONLY the first 16 characters will be 751 751 ! used. If NPREF is positive and the length of PREFIX is less 752 752 ! than NPREF, a copy of PREFIX extended with blanks to length … … 1055 1055 END SUBROUTINE XERCNT 1056 1056 1057 !DECK J4SAVE 1058 FUNCTION J4SAVE(IWHICH, IVALUE, ISET) 1059 IMPLICIT NONE 1060 !***BEGIN PROLOGUE J4SAVE 1061 !***SUBSIDIARY 1062 !***PURPOSE Save or reCALL global variables needed by error 1063 ! handling routines. 1064 !***LIBRARY SLATEC (XERROR) 1065 !***TYPE INTEGER (J4SAVE-I) 1066 !***KEYWORDS ERROR MESSAGES, ERROR NUMBER, RECALL, SAVE, XERROR 1067 !***AUTHOR Jones, R. E., (SNLA) 1068 !***DESCRIPTION 1069 ! 1070 ! Abstract 1071 ! J4SAVE saves and recalls several global variables needed 1072 ! by the library error handling routines. 1073 ! 1074 ! Description of Parameters 1075 ! --Input-- 1076 ! IWHICH - Index of item desired. 1077 ! = 1 Refers to current error number. 1078 ! = 2 Refers to current error control flag. 1079 ! = 3 Refers to current unit number to which error 1080 ! messages are to be sent. (0 means use standard.) 1081 ! = 4 Refers to the maximum number of times any 1082 ! message is to be printed (as set by XERMAX). 1083 ! = 5 Refers to the total number of units to which 1084 ! each error message is to be written. 1085 ! = 6 Refers to the 2nd unit for error messages 1086 ! = 7 Refers to the 3rd unit for error messages 1087 ! = 8 Refers to the 4th unit for error messages 1088 ! = 9 Refers to the 5th unit for error messages 1089 ! IVALUE - The value to be set for the IWHICH-th parameter, 1090 ! if ISET is .TRUE. . 1091 ! ISET - If ISET=.TRUE., the IWHICH-th parameter will BE 1092 ! given the value, IVALUE. If ISET=.FALSE., the 1093 ! IWHICH-th parameter will be unchanged, and IVALUE 1094 ! is a dummy parameter. 1095 ! --Output-- 1096 ! The (old) value of the IWHICH-th parameter will be returned 1097 ! in the function value, J4SAVE. 1098 ! 1099 !***SEE ALSO XERMSG 1100 !***REFERENCES R. E. Jones and D. K. Kahaner, XERROR, the SLATEC 1101 ! Error-handling Package, SAND82-0800, Sandia 1102 ! Laboratories, 1982. 1103 !***ROUTINES CALLED (NONE) 1104 !***REVISION HISTORY (YYMMDD) 1105 ! 790801 DATE WRITTEN 1106 ! 891214 Prologue converted to Version 4.0 format. (BAB) 1107 ! 900205 Minor modifications to prologue. (WRB) 1108 ! 900402 Added TYPE section. (WRB) 1109 ! 910411 Added KEYWORDS section. (WRB) 1110 ! 920501 Reformatted the REFERENCES section. (WRB) 1111 !***END PROLOGUE J4SAVE 1112 LOGICAL :: ISET 1113 INTEGER :: IPARAM(9) 1114 SAVE IPARAM 1115 DATA IPARAM(1), IPARAM(2), IPARAM(3), IPARAM(4)/0, 2, 0, 10/ 1116 DATA IPARAM(5)/1/ 1117 DATA IPARAM(6), IPARAM(7), IPARAM(8), IPARAM(9)/0, 0, 0, 0/ 1118 INTEGER :: J4SAVE, IWHICH, IVALUE 1119 !***FIRST EXECUTABLE STATEMENT J4SAVE 1120 J4SAVE = IPARAM(IWHICH) 1121 IF (ISET) IPARAM(IWHICH) = IVALUE 1122 1123 END FUNCTION J4SAVE 1124 1057 1125 1058 1126 END MODULE lmdz_xer -
LMDZ6/branches/Amaury_dev/libf/misc/q_sat.f90
r5105 r5116 19 19 !====================================================================== 20 20 21 integer:: np21 INTEGER :: np 22 22 REAL :: temp(np),pres(np),qsat(np) 23 23 … … 39 39 PARAMETER (retv=28.9644/18.0153 - 1.0) 40 40 41 real:: zqsat42 integer:: ip41 REAL :: zqsat 42 INTEGER :: ip 43 43 44 44 ! ------------------------------------------------------------------ … … 47 47 do ip=1,np 48 48 49 ! write(*,*)'kelvin,millibar=',kelvin,millibar50 ! write(*,*)'temp,pres=',temp(ip),pres(ip)49 ! WRITE(*,*)'kelvin,millibar=',kelvin,millibar 50 ! WRITE(*,*)'temp,pres=',temp(ip),pres(ip) 51 51 52 52 IF (temp(ip) <= rtt) THEN … … 63 63 64 64 qsat(ip)= zqsat 65 ! write(*,*)'qsat=',qsat(ip)65 ! WRITE(*,*)'qsat=',qsat(ip) 66 66 67 67 enddo -
LMDZ6/branches/Amaury_dev/libf/misc/regr1_step_av_m.F90
r5113 r5116 30 30 ! "vs" has rank 1. 31 31 32 use lmdz_assert_eq, only: assert_eq33 use lmdz_assert, only: assert34 use interpolation, only: locate32 use lmdz_assert_eq, ONLY: assert_eq 33 use lmdz_assert, ONLY: assert 34 use lmdz_interpolation, ONLY: locate 35 35 36 36 real, intent(in):: vs(:) ! values of steps on the source grid … … 81 81 END DO 82 82 83 end functionregr11_step_av83 END FUNCTION regr11_step_av 84 84 85 85 !******************************************** … … 89 89 ! "vs" has rank 2. 90 90 91 use lmdz_assert_eq, only: assert_eq92 use lmdz_assert, only: assert93 use interpolation, only: locate91 use lmdz_assert_eq, ONLY: assert_eq 92 use lmdz_assert, ONLY: assert 93 use lmdz_interpolation, ONLY: locate 94 94 95 95 real, intent(in):: vs(:, :) ! values of steps on the source grid … … 141 141 END DO 142 142 143 end functionregr12_step_av143 END FUNCTION regr12_step_av 144 144 145 145 !******************************************** … … 149 149 ! "vs" has rank 3. 150 150 151 use lmdz_assert_eq, only: assert_eq152 use lmdz_assert, only: assert153 use interpolation, only: locate151 use lmdz_assert_eq, ONLY: assert_eq 152 use lmdz_assert, ONLY: assert 153 use lmdz_interpolation, ONLY: locate 154 154 155 155 real, intent(in):: vs(:, :, :) ! values of steps on the source grid … … 202 202 END DO 203 203 204 end functionregr13_step_av204 END FUNCTION regr13_step_av 205 205 206 206 !******************************************** … … 210 210 ! "vs" has rank 4. 211 211 212 use lmdz_assert_eq, only: assert_eq213 use lmdz_assert, only: assert214 use interpolation, only: locate212 use lmdz_assert_eq, ONLY: assert_eq 213 use lmdz_assert, ONLY: assert 214 use lmdz_interpolation, ONLY: locate 215 215 216 216 real, intent(in):: vs(:, :, :, :) ! values of steps on the source grid … … 264 264 END DO 265 265 266 end functionregr14_step_av266 END FUNCTION regr14_step_av 267 267 268 268 end module regr1_step_av_m -
LMDZ6/branches/Amaury_dev/libf/misc/regr_conserv_m.F90
r5113 r5116 3 3 USE lmdz_assert_eq, ONLY: assert_eq 4 4 USE lmdz_assert, ONLY: assert 5 USEinterpolation, ONLY: locate5 use lmdz_interpolation, ONLY: locate 6 6 7 7 IMPLICIT NONE -
LMDZ6/branches/Amaury_dev/libf/misc/regr_lint_m.F90
r5113 r5116 3 3 USE lmdz_assert_eq, ONLY: assert_eq 4 4 USE lmdz_assert, ONLY: assert 5 USEinterpolation, ONLY: hunt5 use lmdz_interpolation, ONLY: hunt 6 6 7 7 IMPLICIT NONE -
LMDZ6/branches/Amaury_dev/libf/misc/vampir.F90
r5113 r5116 20 20 #ifdef USE_VT 21 21 include 'VT.inc' 22 integer:: ierr22 INTEGER :: ierr 23 23 24 24 CALL VTSYMDEF(VTcaldyn,"caldyn","caldyn",ierr) … … 33 33 #ifdef USE_MPE 34 34 include 'mpe_logf.h' 35 integer:: ierr,i35 INTEGER :: ierr,i 36 36 37 37 DO i=1,nb_inst … … 54 54 #ifdef USE_VT 55 55 include 'VT.inc' 56 integer:: ierr56 INTEGER :: ierr 57 57 58 58 CALL VTBEGIN(number,ierr) … … 60 60 #ifdef USE_MPE 61 61 include 'mpe_logf.h' 62 integer:: ierr,i62 INTEGER :: ierr,i 63 63 ierr = MPE_Log_event( MPE_begin(number), 0, '' ) 64 64 #endif … … 71 71 #ifdef USE_VT 72 72 include 'VT.inc' 73 integer:: ierr73 INTEGER :: ierr 74 74 75 75 CALL VTEND(number,ierr) … … 78 78 #ifdef USE_MPE 79 79 include 'mpe_logf.h' 80 integer:: ierr,i80 INTEGER :: ierr,i 81 81 ierr = MPE_Log_event( MPE_end(number), 0, '' ) 82 82 #endif -
LMDZ6/branches/Amaury_dev/libf/misc/write_field.F90
r5113 r5116 12 12 integer, dimension(MaxWriteField), save :: FieldVarId 13 13 integer, dimension(MaxWriteField), save :: FieldIndex 14 character(len= 255), dimension(MaxWriteField) :: FieldName14 CHARACTER(LEN = 255), dimension(MaxWriteField) :: FieldName 15 15 16 16 integer, save :: NbField = 0 … … 23 23 function GetFieldIndex(name) 24 24 IMPLICIT NONE 25 integer:: GetFieldindex26 character(len= *) :: name27 28 character(len= 255) :: TrueName29 integer:: i25 INTEGER :: GetFieldindex 26 CHARACTER(LEN = *) :: name 27 28 CHARACTER(LEN = 255) :: TrueName 29 INTEGER :: i 30 30 31 31 TrueName = TRIM(ADJUSTL(name)) … … 33 33 GetFieldIndex = -1 34 34 do i = 1, NbField 35 if (TrueName==FieldName(i)) then35 if (TrueName==FieldName(i)) THEN 36 36 GetFieldIndex = i 37 37 exit 38 38 endif 39 39 enddo 40 end functionGetFieldIndex40 END FUNCTION GetFieldIndex 41 41 42 42 subroutine WriteField3d(name, Field) 43 43 IMPLICIT NONE 44 character(len= *) :: name44 CHARACTER(LEN = *) :: name 45 45 real, dimension(:, :, :) :: Field 46 46 integer, dimension(3) :: Dim … … 49 49 CALL WriteField_gen(name, Field, Dim(1), Dim(2), Dim(3)) 50 50 51 end subroutineWriteField3d51 END SUBROUTINE WriteField3d 52 52 53 53 subroutine WriteField2d(name, Field) 54 54 IMPLICIT NONE 55 character(len= *) :: name55 CHARACTER(LEN = *) :: name 56 56 real, dimension(:, :) :: Field 57 57 integer, dimension(2) :: Dim … … 60 60 CALL WriteField_gen(name, Field, Dim(1), Dim(2), 1) 61 61 62 end subroutineWriteField2d62 END SUBROUTINE WriteField2d 63 63 64 64 subroutine WriteField1d(name, Field) 65 65 IMPLICIT NONE 66 character(len= *) :: name66 CHARACTER(LEN = *) :: name 67 67 real, dimension(:) :: Field 68 68 integer, dimension(1) :: Dim … … 71 71 CALL WriteField_gen(name, Field, Dim(1), 1, 1) 72 72 73 end subroutineWriteField1d73 END SUBROUTINE WriteField1d 74 74 75 75 subroutine WriteField_gen(name, Field, dimx, dimy, dimz) 76 76 IMPLICIT NONE 77 character(len= *) :: name78 integer:: dimx, dimy, dimz77 CHARACTER(LEN = *) :: name 78 INTEGER :: dimx, dimy, dimz 79 79 real, dimension(dimx, dimy, dimz) :: Field 80 80 integer, dimension(dimx * dimy * dimz) :: ndex 81 integer:: status82 integer:: index83 integer:: start(4)84 integer:: count(4)81 INTEGER :: status 82 INTEGER :: index 83 INTEGER :: start(4) 84 INTEGER :: count(4) 85 85 86 86 Index = GetFieldIndex(name) 87 if (Index==-1) then87 if (Index==-1) THEN 88 88 CALL CreateNewField(name, dimx, dimy, dimz) 89 89 Index = GetFieldIndex(name) … … 105 105 status = nf90_sync(FieldId(Index)) 106 106 107 end subroutineWriteField_gen107 END SUBROUTINE WriteField_gen 108 108 109 109 subroutine CreateNewField(name, dimx, dimy, dimz) 110 110 IMPLICIT NONE 111 character(len= *) :: name112 integer:: dimx, dimy, dimz113 integer:: TabDim(4)114 integer:: status111 CHARACTER(LEN = *) :: name 112 INTEGER :: dimx, dimy, dimz 113 INTEGER :: TabDim(4) 114 INTEGER :: status 115 115 116 116 NbField = NbField + 1 … … 126 126 status = nf90_enddef(FieldId(NbField)) 127 127 128 end subroutineCreateNewField128 END SUBROUTINE CreateNewField 129 129 130 130 subroutine write_field1D(name, Field) … … 132 132 133 133 integer, parameter :: MaxDim = 1 134 character(len= *) :: name134 CHARACTER(LEN = *) :: name 135 135 real, dimension(:) :: Field 136 136 real, dimension(:), allocatable :: New_Field 137 character(len= 20) :: str137 CHARACTER(LEN = 20) :: str 138 138 integer, dimension(MaxDim) :: Dim 139 integer:: i, nb139 INTEGER :: i, nb 140 140 integer, parameter :: id = 10 141 141 integer, parameter :: NbCol = 4 142 integer:: ColumnSize143 integer:: pos144 character(len= 255) :: form145 character(len= 255) :: MaxLen142 INTEGER :: ColumnSize 143 INTEGER :: pos 144 CHARACTER(LEN = 255) :: form 145 CHARACTER(LEN = 255) :: MaxLen 146 146 147 147 open(unit = id, file = name // '.field', form = 'formatted', status = 'replace') … … 155 155 nb = nb + 1 156 156 157 if (MOD(nb, NbCol)==0) then157 if (MOD(nb, NbCol)==0) THEN 158 158 form = '(t' // trim(int2str(pos)) // ',i' // trim(MaxLen) // '," ---> ",g22.16,/)' 159 159 Pos = 2 … … 167 167 close(id) 168 168 169 end subroutinewrite_field1D169 END SUBROUTINE write_field1D 170 170 171 171 subroutine write_field2D(name, Field) … … 173 173 174 174 integer, parameter :: MaxDim = 2 175 character(len= *) :: name175 CHARACTER(LEN = *) :: name 176 176 real, dimension(:, :) :: Field 177 177 real, dimension(:, :), allocatable :: New_Field 178 character(len= 20) :: str178 CHARACTER(LEN = 20) :: str 179 179 integer, dimension(MaxDim) :: Dim 180 integer:: i, j, nb180 INTEGER :: i, j, nb 181 181 integer, parameter :: id = 10 182 182 integer, parameter :: NbCol = 4 183 integer:: ColumnSize184 integer:: pos, offset185 character(len= 255) :: form186 character(len= 255) :: spacing183 INTEGER :: ColumnSize 184 INTEGER :: pos, offset 185 CHARACTER(LEN = 255) :: form 186 CHARACTER(LEN = 255) :: spacing 187 187 188 188 open(unit = id, file = name // '.field', form = 'formatted', status = 'replace') … … 201 201 nb = nb + 1 202 202 203 if (MOD(nb, NbCol)==0) then203 if (MOD(nb, NbCol)==0) THEN 204 204 form = '(t' // trim(int2str(pos)) // & 205 205 ',"(' // trim(int2str(j)) // ',' & … … 218 218 write (id, form, advance = 'no') Field(j, i) 219 219 enddo 220 if (MOD(nb, NbCol)==0) then220 if (MOD(nb, NbCol)==0) THEN 221 221 write (id, spacing) 222 222 else … … 226 226 enddo 227 227 228 end subroutinewrite_field2D228 END SUBROUTINE write_field2D 229 229 230 230 subroutine write_field3D(name, Field) … … 232 232 233 233 integer, parameter :: MaxDim = 3 234 character(len= *) :: name234 CHARACTER(LEN = *) :: name 235 235 real, dimension(:, :, :) :: Field 236 236 real, dimension(:, :, :), allocatable :: New_Field 237 237 integer, dimension(MaxDim) :: Dim 238 integer:: i, j, k, nb238 INTEGER :: i, j, k, nb 239 239 integer, parameter :: id = 10 240 240 integer, parameter :: NbCol = 4 241 integer:: ColumnSize242 integer:: pos, offset243 character(len= 255) :: form244 character(len= 255) :: spacing241 INTEGER :: ColumnSize 242 INTEGER :: pos, offset 243 CHARACTER(LEN = 255) :: form 244 CHARACTER(LEN = 255) :: spacing 245 245 246 246 open(unit = id, file = name // '.field', form = 'formatted', status = 'replace') … … 264 264 nb = nb + 1 265 265 266 if (MOD(nb, NbCol)==0) then266 if (MOD(nb, NbCol)==0) THEN 267 267 form = '(t' // trim(int2str(pos)) // & 268 268 ',"(' // trim(int2str(k)) // ',' & … … 284 284 write (id, form, advance = 'no') Field(k, j, i) 285 285 enddo 286 if (MOD(nb, NbCol)==0) then286 if (MOD(nb, NbCol)==0) THEN 287 287 write (id, spacing) 288 288 else … … 296 296 close(id) 297 297 298 end subroutinewrite_field3D298 END SUBROUTINE write_field3D 299 299 300 300 end module write_field -
LMDZ6/branches/Amaury_dev/libf/misc/wxios.F90
r5112 r5116 359 359 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 360 360 SUBROUTINE wxios_domain_param(dom_id) 361 USE dimphy, only: klon361 USE dimphy, ONLY: klon 362 362 USE lmdz_phys_transfert_para, ONLY: gather, bcast 363 USE lmdz_phys_para, only: jj_nb, jj_begin, jj_end, ii_begin, ii_end, &363 USE lmdz_phys_para, ONLY: jj_nb, jj_begin, jj_end, ii_begin, ii_end, & 364 364 mpi_size, mpi_rank, klon_mpi, & 365 365 is_sequential, is_south_pole_dyn 366 USE lmdz_grid_phy, only: nbp_lon, nbp_lat, klon_glo366 USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat, klon_glo 367 367 USE lmdz_print_control, ONLY: prt_level, lunout 368 368 USE lmdz_geometry … … 390 390 io_lat(1)=rlat_glo(1) 391 391 io_lat(nbp_lat)=rlat_glo(klon_glo) 392 IF ((nbp_lon*nbp_lat) > 1) then392 IF ((nbp_lon*nbp_lat) > 1) THEN 393 393 DO i=2,nbp_lat-1 394 394 io_lat(i)=rlat_glo(2+(i-2)*nbp_lon) … … 532 532 533 533 ! Ehouarn: New way to declare axis, without axis_group: 534 if (PRESENT(positif) .AND. PRESENT(bnds)) then534 if (PRESENT(positif) .AND. PRESENT(bnds)) THEN 535 535 CALL xios_set_axis_attr(trim(axis_id),n_glo=axis_size,value=axis_value, & 536 536 positive=positif, bounds=bnds) 537 else if (PRESENT(positif)) then537 else if (PRESENT(positif)) THEN 538 538 CALL xios_set_axis_attr(trim(axis_id),n_glo=axis_size,value=axis_value, & 539 539 positive=positif) 540 else if (PRESENT(bnds)) then540 else if (PRESENT(bnds)) THEN 541 541 CALL xios_set_axis_attr(trim(axis_id),n_glo=axis_size,value=axis_value, & 542 542 bounds=bnds) … … 605 605 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 606 606 SUBROUTINE wxios_add_field(fieldname, fieldgroup, fieldlongname, fieldunit) 607 USE netcdf, only: nf90_fill_real607 USE netcdf, ONLY: nf90_fill_real 608 608 609 609 IMPLICIT NONE
Note: See TracChangeset
for help on using the changeset viewer.