Changeset 5214 for LMDZ6/trunk/libf/dyn3d_common
- Timestamp:
- Sep 22, 2024, 10:07:56 PM (4 months ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
LMDZ6/trunk/libf/dyn3d_common/iso_verif_dyn.F90
r5213 r5214 1 function iso_verif_noNaN_nostop(x,err_msg) 2 implicit none 3 ! si x est NaN, on affiche message 4 ! d'erreur et return 1 si erreur 5 6 ! input: 7 real x 8 character*(*) err_msg ! message d''erreur à afficher 9 10 ! output 11 real borne 12 parameter (borne=1e19) 13 integer iso_verif_noNaN_nostop 14 15 if ((x.gt.-borne).and.(x.lt.borne)) then 16 iso_verif_noNAN_nostop=0 17 else 18 write(*,*) 'erreur detectee par iso_verif_nonNaN:' 19 write(*,*) err_msg 20 write(*,*) 'x=',x 21 iso_verif_noNaN_nostop=1 22 endif 23 24 return 25 end 26 27 function iso_verif_egalite_nostop 28 : (a,b,err_msg) 29 implicit none 30 ! compare a et b. Si pas egal, on affiche message 31 ! d'erreur et stoppe 32 ! pour egalite, on verifie erreur absolue et arreur relative 33 34 ! input: 35 real a, b 36 character*(*) err_msg ! message d''erreur à afficher 37 38 ! locals 39 real errmax ! erreur maximale en absolu. 40 real errmaxrel ! erreur maximale en relatif autorisée 41 parameter (errmax=1e-8) 42 parameter (errmaxrel=1e-3) 43 44 ! output 45 integer iso_verif_egalite_nostop 46 47 iso_verif_egalite_nostop=0 48 49 if (abs(a-b).gt.errmax) then 50 if (abs((a-b)/max(max(abs(b),abs(a)),1e-18)) 51 : .gt.errmaxrel) then 52 write(*,*) 'erreur detectee par iso_verif_egalite:' 53 write(*,*) err_msg 54 write(*,*) 'a=',a 55 write(*,*) 'b=',b 56 iso_verif_egalite_nostop=1 57 endif 58 endif 59 60 return 61 end 1 LOGICAL FUNCTION iso_verif_noNaN_nostop(x, err_msg) RESULT(lerr) 2 IMPLICIT NONE 3 ! If "x" is NaN, print an error message . 4 REAL, INTENT(IN) :: x 5 CHARACTER(LEN=*), INTENT(IN) :: err_msg 6 REAL, PARAMETER :: borne = 1e19 7 lerr = x > -borne .AND. x < borne 8 IF(.NOT.lerr) RETURN 9 WRITE(*,*) 'erreur detectee par iso_verif_nonNaN:' 10 WRITE(*,*) err_msg 11 WRITE(*,*) 'x=',x 12 END FUNCTION iso_verif_noNaN_nostop 62 13 63 14 64 function iso_verif_aberrant_nostop 65 : (x,iso,q,err_msg) 15 LOGICAL FUNCTION iso_verif_egalite_nostop(a, b, err_msg) RESULT(lerr) 16 IMPLICIT NONE 17 ! Compare "a" and "b". If a/=b, print an error message. 18 ! Both absolute and relative errors are checked for equality. 19 REAL, INTENT(IN) :: a, b 20 CHARACTER(LEN=*), INTENT(IN) :: err_msg 21 REAL, PARAMETER :: errmax = 1e-8, & ! max absolute error 22 errmaxrel = 1e-3 ! max relative error 23 lerr = ABS(a-b) > errmax 24 IF(.NOT.lerr) RETURN 25 lerr = ABS( (a-b) / MAX(MAX(ABS(b), ABS(a)),1e-18) ) > errmaxrel 26 IF(.NOT.lerr) RETURN 27 WRITE(*,*) 'erreur detectee par iso_verif_egalite:' 28 WRITE(*,*) err_msg 29 WRITE(*,*) 'a=',a 30 WRITE(*,*) 'b=',b 31 END FUNCTION iso_verif_egalite_nostop 32 33 34 LOGICAL FUNCTION iso_verif_aberrant_nostop(x, iso, q, err_msg) RESULT(lerr) 66 35 #ifdef CPP_IOIPSL 67 36 USE IOIPSL, ONLY: getin 68 37 #else 69 38 USE ioipsl_getincom, ONLY: getin 70 39 #endif 71 USE infotrac, ONLY: isoName, getKey 72 implicit none 73 74 ! input: 75 real x,q 76 integer iso ! 2=HDO, 1=O18 77 character*(*) err_msg ! message d''erreur à afficher 40 USE iso_params_mod, ONLY: tnat_HDO 41 IMPLICIT NONE 42 REAL, INTENT(IN) :: x, q 43 INTEGER, INTENT(IN) :: iso ! 2=HDO, 1=O18 44 CHARACTER(LEN=*), INTENT(IN) :: err_msg 78 45 79 ! locals 80 real qmin,deltaD 81 real deltaDmax,deltaDmin,tnat 82 parameter (qmin=1e-11) 83 parameter (deltaDmax=200.0,deltaDmin=-999.9) 84 LOGICAL, SAVE :: ltnat1 85 LOGICAL, SAVE :: lFirst=.TRUE. 46 REAL, PARAMETER :: qmin = 1e-11, & 47 deltaDmax = 200.0, & 48 deltaDmin =-999.9 49 LOGICAL :: ltnat1 50 LOGICAL, SAVE :: lFirst=.TRUE. 51 REAL, SAVE :: tnat 52 REAL :: deltaD 53 IF(lFirst) THEN 54 ltnat1 = .TRUE.; CALL getin('tnateq1', ltnat1) 55 tnat = tnat_HDO; IF(ltnat1) tnat = 1.0 56 lFirst = .FALSE. 57 END IF 58 lerr = q > qmin 59 IF(.NOT.lerr) RETURN 60 deltaD = (x / q /tnat - 1.) * 1000. 61 lerr = deltaD > deltaDmax .OR. deltaD < deltaDmin 62 IF(.NOT.lerr) RETURN 63 WRITE(*,*) 'erreur detectee par iso_verif_aberrant:' 64 WRITE(*,*) err_msg 65 WRITE(*,*) 'q=',q 66 WRITE(*,*) 'deltaD=',deltaD 67 WRITE(*,*) 'iso=',iso 68 END FUNCTION iso_verif_aberrant_nostop 86 69 87 ! output88 integer iso_verif_aberrant_nostop89 90 IF(lFirst) THEN91 ltnat1 = .TRUE.; CALL getin('tnateq1', ltnat1)92 lFirst = .FALSE.93 END IF94 iso_verif_aberrant_nostop=095 96 ! verifier que HDO est raisonable97 if (q.gt.qmin) then98 IF(ltnat1) THEN99 tnat = 1.0100 ELSE IF(getKey('tnat', tnat, isoName(iso))) THEN101 err_msg = 'Missing isotopic parameter "tnat"'102 iso_verif_aberrant_nostop=1103 RETURN104 END IF105 deltaD=(x/q/tnat-1)*1000106 if ((deltaD.gt.deltaDmax).or.(deltaD.lt.deltaDmin)) then107 write(*,*) 'erreur detectee par iso_verif_aberrant:'108 write(*,*) err_msg109 write(*,*) 'q=',q110 write(*,*) 'deltaD=',deltaD111 write(*,*) 'iso=',iso112 iso_verif_aberrant_nostop=1113 endif !if ((deltaD.gt.deltaDmax).or.(deltaD.lt.deltaDmin)) then114 endif !if (q(i,k,iq).gt.qmin) then115 116 117 return118 end119
Note: See TracChangeset
for help on using the changeset viewer.