Welcome, Guest
Username: Password: Remember me

TOPIC: modification of Tracers in Fortran script

modification of Tracers in Fortran script 10 years 11 months ago #11256

  • 716469
  • 716469's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 303
  • Thank you received: 6
Dear Users,

Can anyone help me with Fortran script modification. I used the Traces Initialization field as example from validation case 119_stratification, which produce 2 layers stratification. I would like to have three large well defined layers with different values of salinity: 0, 24 and 34, but I am not sure how to write the code correctly. Also I would like to add the Temperature tracer to the script as well with values: -0.29, 1 and 4.3. The current script is :

IF(NTRAC.NE.0) THEN
DO ITRAC=1,NTRAC
! CALL OS('X=C ',X=TA%ADR(ITRAC)%P,C=TRAC0(ITRAC))
DO IPLAN=1,NPLAN
DO I=1,NPOIN2
J=NPOIN2*(IPLAN-1)+I
IF(IPLAN.GT.18) THEN
TA%ADR(ITRAC)%P%R(J)=24.D0
ELSE
TA%ADR(ITRAC)%P%R(J)=34.D0
ENDIF
ENDDO
ENDDO
ENDDO
ENDIF

Please advise. Thank you.

Kind Regards!

Violeta
The administrator has disabled public write access.

modification of Tracers in Fortran script 10 years 11 months ago #11257

  • jmhervouet
  • jmhervouet's Avatar
Hello,

That's about it but I do not see where you have a value equal to 0, in your implementation you put only 24 or 34:

IF(IPLAN.GT.18) THEN
TA%ADR(ITRAC)%P%R(J)=24.D0
ELSE
TA%ADR(ITRAC)%P%R(J)=34.D0
ENDIF

Now to treat temperature and salinity, I would do something like this inside the loop on ITRAC:

IF(TA%ADR(ITRAC)%P%NAME(1:4).EQ.'SALI') THEN
here your block DO IPLAN=1,NPLAN with 24., 34. and 0.
ELSEIF(TA%ADR(ITRAC)%P%NAME(1:4).EQ.'TEMP') THEN
here your block DO IPLAN=1,NPLAN with -0.29, 1. and 4.3
ELSE
! in case you have other tracers
CALL OS('X=C ',X=TA%ADR(ITRAC)%P,C=TRAC0(ITRAC))
ENDIF


And that's it!

Regards,

Jean-Michel Hervouet
The administrator has disabled public write access.

modification of Tracers in Fortran script 10 years 11 months ago #11259

  • 716469
  • 716469's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 303
  • Thank you received: 6
Dear Jean-Michele,

Thank you for your reply. Unfortunately I am new to fortran yet and had some problems to set up the tracers value in Fortran file. Thanks for advice on including temperature to the file as well, but it did not work for me yet. So I decided to do simplier task with salinity for a moment. I am running similar case to 119_stratification but trying to create three salinity layers instead of two. The case with two salinity layers produces realistic results but when I add extra line for another layer in Fortran then it runs but domain looks empty to me, as there is no watter mass balance info in result files. I have below on Fortran file, the total number of layers is 30. When I succed with this case then I will try to add temperature as well. Please advise. Thank you.

IF(NTRAC.NE.0) THEN
DO ITRAC=1,NTRAC
DO IPLAN=1,NPLAN
DO I=1,NPOIN2
J=NPOIN2*(IPLAN-1)+I
IF(IPLAN.GT.28) THEN
TA%ADR(ITRAC)%P%R(J)=0.D0
IF(IPLAN.GT.18.AND.IPLAN.LE.28) THEN
TA%ADR(ITRAC)%P%R(J)=24.D0
ELSE
TA%ADR(ITRAC)%P%R(J)=34.D0
ENDIF
ENDIF
ENDDO
ENDDO
ENDDO
ENDIF
Kind Regards!

Violeta
The administrator has disabled public write access.

modification of Tracers in Fortran script 10 years 11 months ago #11260

  • 716469
  • 716469's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 303
  • Thank you received: 6
Dear Jean-Michel,

Ignore my previous post, it is working now, I forgot to reactivate below line.
! CALL OS('X=C ',X=TA%ADR(ITRAC)%P,C=TRAC0(ITRAC))

So now I will try to work on adding Temperature to the script. Thanks.

Kind Regards!

Violeta
The administrator has disabled public write access.

modification of Tracers in Fortran script 10 years 11 months ago #11261

  • jmhervouet
  • jmhervouet's Avatar
Hello,

There is a mistake in your IF tests, it should be :

IF(NTRAC.NE.0) THEN
DO ITRAC=1,NTRAC
DO IPLAN=1,NPLAN
DO I=1,NPOIN2
J=NPOIN2*(IPLAN-1)+I
IF(IPLAN.GT.28) THEN
TA%ADR(ITRAC)%P%R(J)=0.D0
ELSEIF(IPLAN.GT.18.AND.IPLAN.LE.28) THEN
TA%ADR(ITRAC)%P%R(J)=24.D0
ELSE
TA%ADR(ITRAC)%P%R(J)=34.D0
ENDIF
ENDDO
ENDDO
ENDDO
ENDIF


Regards,

JMH
The administrator has disabled public write access.

modification of Tracers in Fortran script 10 years 11 months ago #11262

  • 716469
  • 716469's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 303
  • Thank you received: 6
Thank you very much Jean-Michel. After running this case I will see if I could combine it with Temperature. I will post if any questions. Thanks again.

Kind Regards!

Violeta
The administrator has disabled public write access.

modification of Tracers in Fortran script 10 years 11 months ago #11276

  • 716469
  • 716469's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 303
  • Thank you received: 6
Dear Jean-Michel,

Thanks for your help last week with Fortran tracers coding. The salinity with three layers worked fine now, but I still have problem with script when I add the temperature. I changed it slightly many times but when I run the case it run ok but when I looked at results it did not really take in consideration the requested tracers. So there must be some mistakes in my script in IF/ELSE statemnets. I have it below. Please advise. Thanks.

! TRACERS INITIALIZATION
!
IF(NTRAC.NE.0) THEN
DO ITRAC=1,NTRAC
CALL OS('X=C ',X=TA%ADR(ITRAC)%P,C=TRAC0(ITRAC))
IF(TA%ADR(ITRAC)%P%NAME(1:4).EQ.'SALINITY') THEN
DO IPLAN=1,NPLAN
DO I=1,NPOIN2
J=NPOIN2*(IPLAN-1)+I
IF(IPLAN.GT.18) THEN
TA%ADR(ITRAC)%P%R(J)=0.D0
ELSEIF (IPLAN.GT.15.AND.IPLAN.LE.28) THEN
TA%ADR(ITRAC)%P%R(J)=14.D0
ELSE
TA%ADR(ITRAC)%P%R(J)=34.D0
ENDIF
ENDDO
ENDDO
ELSEIF(TA%ADR(ITRAC)%P%NAME(1:4).EQ.'TEMPERATURE ºC') THEN
DO IPLAN=1,NPLAN
DO I=1,NPOIN2
J=NPOIN2*(IPLAN-1)+I
IF(IPLAN.GT.18) THEN
TA%ADR(ITRAC)%P%R(J)=-0.29D0
ELSEIF (IPLAN.GT.15.AND.IPLAN.LE.28) THEN
TA%ADR(ITRAC)%P%R(J)=1.D0
ELSE
TA%ADR(ITRAC)%P%R(J)=4.3D0
ENDIF
ENDDO
ENDDO
ENDIF
ENDDO
ENDIF



Kind Regards!

Violeta
The administrator has disabled public write access.

modification of Tracers in Fortran script 10 years 11 months ago #11456

  • jmhervouet
  • jmhervouet's Avatar
Hello,

I am back after 3 weeks off. The lines that seem to me wrong in your code are:

IF(TA%ADR(ITRAC)%P%NAME(1:4).EQ.'SALINITY') THEN

and:

ELSEIF(TA%ADR(ITRAC)%P%NAME(1:4).EQ.'TEMPERATURE ºC') THEN

because you compare a string of 4 letters to much longer strings, you should write:

IF(TA%ADR(ITRAC)%P%NAME(1:4).EQ.'SALI') THEN

and:

ELSEIF(TA%ADR(ITRAC)%P%NAME(1:4).EQ.'TEMP') THEN


and it will probably work.

With best regards,

Jean-Michel Hervouet
The administrator has disabled public write access.
Moderators: pham

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.